4 ms·
Curious to read this and not see a reference to Ruby. In Ruby hashes are ordered by insertion, can have any object as keys, but the hash key value can be defin
by noneeeed 5y ago
Curious to read this and not see a reference to Ruby.
In Ruby hashes are ordered by insertion, can have any object as keys, but the hash key value can be defined on a class by class basis (by overriding the default `hash` method on the class).
The ordering is one of those features that I need very infrequently, but when I do it significantly simplifies that bit of code.
I've always found the usefulness and flexibilty of Ruby's hashes to be a double-edged sword though: they are extremely useful, but this leads people to use them in situations where defining a proper class might be better for long-term maintenance.
- weatherlight 5y agoI've used this feature of Ruby Hashes to create something that behaves like a a LRU cache :)
- noneeeed 5y agoInteresting, I'm trying to work out how that would work. Would you mind giving a quick overview?