Go: what determines the iteration order for map keys?

后端 未结 4 633
[愿得一人]
[愿得一人] 2021-01-17 15:27

The Go Programming Language Specification says:

3. The iteration order over maps is not specified. [...]

That\'s to be expected

4条回答
  •  梦谈多话
    2021-01-17 16:12

    If the specs say the iteration order is not specified then a specific order in specific cases is not ruled out.

    The point is one cannot rely on that order in any case, not even in some special case. The implementation is free to change this behavior at any given moment, run time included.

提交回复
热议问题