Maps
Both arrays and slices limit you to using positive integers as indexes, which start from 0
and cannot have gaps in them—this means that even if you want to put data in the slice element at index 99 only, the slice is still going to occupy 100 elements in memory. Maps are more powerful data structures because they allow you to use indexes of various data types as keys to look up your data, as long as these keys are comparable. Comparable means that Go should be able to tell if two values are equal or which value is bigger (or smaller) than the other.
Although Boolean variables are comparable, it makes no sense to use a bool
variable as the key to a map because it only allows for two distinct values. Additionally, although floating point values are comparable, precision issues caused by the internal representation of such values might create bugs and crashes, so you might want to avoid using floating point values as keys to maps.
You might ask, why do...