3 ms·
Same in Go, you can use interface{} values as keys, the concrete values of the interface keys can be a 2-element, 3-element or n-element array values. pack
by tapirl 7y ago
Same in Go, you can use interface{} values as keys, the concrete values of the interface keys can be a 2-element, 3-element or n-element array values.
package main
import "fmt"
func main() {
var m = map[interface{}]int {
[2]int{1, 2}: 12,
[3]int{1, 2, 4}: 123,
[4]int{1, 2, 3, 4}: 1234,
}
fmt.Println(m)
}
- omaranto 7y agoOh, cool! This still doesn't quite get rid of my complaint since the size of an array must be known at compile time, but it's good that they don't all have to be the same size.