4 ms·
Go maps are wonderful examples. If you index into a map, then you get a tuple (val, err), where `err` is non nil if the value exists, and `val` is the value in
by richardwhiuk 5y ago
Go maps are wonderful examples.
If you index into a map, then you get a tuple (val, err), where `err` is non nil if the value exists, and `val` is the value in the map or "the default construction of the value".
Go also silently discards tuple members - e.g. `v = map[4]` is valid, and silently discards the error.
This kind of means that all go maps can accidentally be defaultdicts (in Python terminology), but it's also an excellent way to introduce bugs without meaning to.