re: Tell me, how does Elixir handle a missing key? Besides syntactic sugar, the core ways are: Map.fetch/2 to return nil, Map.fetch!/2 to raise and M...

Besides syntactic sugar, the core ways are: Map.fetch/2 to return nil, Map.fetch!/2 to raise and Map.get/3 to return a default value.

Similar(ish) to Python, I agree this is a better way to handle in general. This is a spot where static typing (and not generics) hurts a bit, as you can't cleanly define an interface/method that can return values of arbitrary types without using interface{}. When you declare a map, it's full structure becomes a type. Meaning map[int]string is a different type from map[string]string. I found a pretty good explanation of what's actually going on with Go's maps. What's funny is the standard lib has list and heap implementations that use interface{}, and I'm not sure why they don't also have a dict package that does the same thing. Here, I just did it.

kōan

Sorry, I'm not sure what language this is so I can only guess that it means something like "banal" in English.

I can read and understand more than 20 languages, I can write the code professionally in more than 10. 4–5 on senior level. I still having difficulties reading Go, despite I already wrote 1000+ LOCs in it.

All those languages knockin' around in your head must be confusing you 😉

I would stick with it and write a few small web applications in it, or don't. It's hardly the best language out there, I just happen to like it a lot.

How is map[string]int pretty darn readable?

I'll agree it's one of the uglier constructs in go. Again, it's worth calling out that I've used maps maybe 2 or 3 times in the 3+ years I've been programming in Go. structs tend to get used more often than in dynamic languages (Python dict hell!!)

code of conduct - report abuse