Maps

Let’s learn about the maps data structure.

What are maps?

Both arrays and slices limit us to using positive integers as indexes. Maps are powerful data structures because they allow us to use indexes of various data types as keys to look up our data as long as these keys are comparable. A practical rule is that we should use a map when we are going to need indexes that are not positive integer numbers or when the integer indexes have big gaps.

Get hands-on with 1200+ tech skills courses.