4 ms·
It's kind of broken that slices are immutable but maps aren't, and that reading a slice can panic but reading a map can't.
by erik_seaberg 8y ago
It's kind of broken that slices are immutable but maps aren't, and that reading a slice can panic but reading a map can't.
- SamWhited 8y agoReading from a nil slice and map feel consistent to me. If you read from a nil map you get the same result as reading a key that is not in a non-nil map (because that key is clearly not in the map because it's nil). Similarly, if you read from a nil slice you get the same result as reading an index that's not in the slice, an out of bounds access.