Hacker News new | ask | show | jobs
by erik_seaberg 2845 days 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.
1 comments

Reading 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.