5 ms·
Man, who doesn't need an ordered hash from time-to-time? The big problem is that most people assume a hash isn't ordered -- so when looking at Ruby source, I w
by bprater 18y ago
Man, who doesn't need an ordered hash from time-to-time?
The big problem is that most people assume a hash isn't ordered -- so when looking at Ruby source, I wonder if this is going to be confusing for awhile?
- dasil003 18y agoShouldn't be too bad. After all, it's a strict superset of the functionality of the old hash. The only confusion will come when someone looks at some code and notices, "Hey, shouldn't this be an ordered hash?" Then they go google "ruby ordered hash" and this blog post pops up and problem solved.
- litewulf 18y agoBasically it'd be nice if you could distinguish between instances where iteration order is important and not important. A separate datatype would do that (at the expense of other things, obviously)
- ivey 18y agoIf you're worried about it in your app, you could always do class OHash < Hash ; end And use OHash as a marker that you're taking advantage of the ordering features. Over time, though, I think this will be a real plus for people learning programming via Ruby. Non-ordered hashes are non-intuitive if you don't know what "hash" means, and think it's just a dictionary.