Thought provoking idea of the day: A colleague suggested that Hash#keys should return a Set, instead of an Array in Ruby 
-
-
-
A hash set is usually implemented as a thin wrapper around a hash map (this is true in Ruby specifically) so no it would not be.
1 reply 0 retweets 0 likes -
Not sure what the benefit would be though since the values are already guaranteed to be unique.
1 reply 0 retweets 0 likes -
Yeah, I agree. I'm guessing that it's just the reinforcement of uniqueness?
1 reply 0 retweets 0 likes -
The idea was that you most commonly want to do set-like operations on the list of keys.
2 replies 0 retweets 0 likes -
If it were up to me we'd only have `each_key` (zero cost to construct), and you'd have to explicitly call `.to_a` on it
1 reply 0 retweets 0 likes -
You're suggesting that Hash#keys returns an object that only responds to each_key?
1 reply 0 retweets 0 likes -
No I'm suggesting not having `.keys` at all. You don't likely need an array, you likely need an `Enumerable`.
1 reply 0 retweets 0 likes -
Ah I see now. Is iteration the most common use case for `keys`?
2 replies 0 retweets 0 likes
And if you do you can always call `.to_a` on it. Makes the linear time op explicit
-
-
Makes sense
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.