3 ms·
It's "missing" because it's not an every day operation, and it's easy to do using other built-in functions. Languages in general should leave out things that a
by compay 18y ago
It's "missing" because it's not an every day operation, and it's easy to do using other built-in functions.
Languages in general should leave out things that are specialized use cases but easy to implement using simpler pieces. If you fill a language's standard library up with "useful" stuff like this, you eventually end up with a morass like PHP.
- antirez 18y agoI'm a minimalist too, but this time I don't agree. You can't have this feature at all if it is not implemented in the core, not in O(1), and is general enough, hash.random_key() will not really bloat the language and it is very clear what it does. If there is 'partition' in Ruby's array I think random_key is not so strange to see inside, especially given that you can't implement it in Ruby itself.