Closed thockin closed 4 months ago
You mean 'map' not 'slice' right?
Oh. Interesting point. Why did it let me do slice indexing? Is that new? Is it sorted, and if so by what?
(dlv) l
> main.main() ./file.go:11 (PC: 0x4960ba)
1: package main
2:
3: import "fmt"
4:
5: func main() {
6: ... s := []string{"zero", "one", "two", "three", "four", "five"}
7: ... m := map[string]int{
8: ... ... "zero": 100, "one": 101, "two": 102,
9: ... ... "three": 103, "four": 104, "five": 105,
10: ... }
=> 11: ... fmt.Println(s, m)
12: }
(dlv) p s[4:]
[]string len: 2, cap: 2, ["four","five"]
(dlv) p m[4:]
map[string]int [
"four": 104,
"five": 105,
...+4 more
]
It appears to be sorted in insert order - is that a quarantee?
Why did it let me do slice indexing? Is that new?
Incremental load, it's been there for years.
Is it sorted, and if so by what? It appears to be sorted in insert order - is that a quarantee?
The order is an implementation detail: it's the order you will get from for range
minus the starting point randomization.
Cool! I did not know this worked. Thanks.
Note the "+28 more".