That's a very good point:

* A map can contain any type of value
* map[value_not_present] is defined to return the zero value
* If the map contains other maps:
(a) you don't want a new map to spring into life every time you access a 
non-existent key - especially not a floating map which isn't stored in the 
parent map
(b) people will *test* for the zero value (v == nil)

Even if you were to panic for a non-existent key, and you forced people to 
use the two-value form, you still need *some* value to return when the 
element is missing.

v, ok := map[key]
if not ok {
    // what value does 'v' have here?
}

So nil maps actually perform an important role.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/48e7c8a2-791f-46e8-8450-7bd82899dd25%40googlegroups.com.

Reply via email to