Reputation: 7738
I'm doing:
{:a => 'hello', :c => 'lovely', :b => 'word'}.values
It returns:
[0] "hello",
[1] "word",
[2] "lovely"
Why did the order change? Any way to easily return the values in the order they were defined in hash?
Upvotes: 0
Views: 156
Reputation: 3870
Rails implements an OrderedHash for Ruby version < 1.9. You can consider implementing it if you're not using Rails.
http://apidock.com/rails/ActiveSupport/OrderedHash
Upvotes: 3