by spraak · 9y ago · 0 comments
I feel this exact same way with Go. E.g.
x := map[string]map[string]int{
"key": map[string]int{
"another": 10,
},
}
Given that the outer type signature says that the `value` of the map should be a `map[string]int` it's sometimes quite annoying to specify that inner type over againYou definitely need to specify the type for an interface, but that makes sense.
The facts are that map literals did change a bit in Go 1.5 (i.e. fairly recently), full literal specification for values could already be elided back then - it was KEYS that required full specification: https://golang.org/doc/go1.5#map_literals
If you go way more back, Go 1 also saved some typing on values, in case they were pointers: https://golang.org/doc/go1#literals