Discussion about this post

User's avatar
drumchaku's avatar

Interestingly enough, maps (dicts) in Python are insertion-ordered. While this is a side effect of the current implementation, this behavior was useful enough that it was made standard. Somehow that doesn't apply to sets, though.

I must be solving a different category of problems in Go, though, because somehow I haven't yet need this behavior. I have one Java application where this is necessary.

Jonathan Ang's avatar

Thank you for this! My code was breaking during an assignment for a Distributed Systems class. it took me a couple of hours to realize that it is by design that Go iterates randomly. I truly held an implicit assumption about map ordering!

2 more comments...

No posts

Ready for more?