2 ms·
Wat 4 is just setting up for wat 5 though. On its own it isn't suprising, many languages use insertion order for iteration, but many others use the hash order.
by grogers 8y ago
Wat 4 is just setting up for wat 5 though. On its own it isn't suprising, many languages use insertion order for iteration, but many others use the hash order. But wat 5 is truly surprising, no other language that I can think of iterates through the same map in different orders (different maps, even clones - sure different order makes sense).
I'm actually impressed by the go devs here, it's a great way to avoid people making assumptions if your order is legitimately randomized.
- int_19h 8y agoIt's not a Go-specific thing, although I'm not aware of anybody else doing it like this, producing different results at runtime for the same map. The more usual approach is to make the hashes themselves random, e.g. by utilizing a seed that's different for every new process. This is the case in .NET Core by default, for example, and in the legacy .NET Framework it's been an off-by-default switch for several years now.