|
|
|
|
|
by spraak
3400 days ago
|
|
> Right now, such a signature would be accepted, but if you tried to use any of map’s methods, you’d get an error that K needs to be Hash and Eq, and have to go back and add those bounds. That’s an example of the compiler being pedantic in a way that can interrupt your flow, and doesn’t really add anything; the fact that we’re using K as a hashmap key essentially forces some additional assumptions about the type. But the compiler is making us spell out those assumptions explicitly in the signature. 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 again |
|
https://play.golang.org/p/m3bLmneArB