4 ms·
Ruby 1.9 still uses hash rocket. I'm using RoR3 on 1.9.2 and I haven't changed any of my hashes. I guess if you want to save some key strokes and you use symb
by jim_h 16y ago
Ruby 1.9 still uses hash rocket. I'm using RoR3 on 1.9.2 and I haven't changed any of my hashes.
I guess if you want to save some key strokes and you use symbols as keys you can use the new syntax.
The other cool/different thing about Hash in 1.9 is that it preserves order.
- deleted 16y ago[deleted]
- JonnieCache 16y agoOuch. Thanks for pointing that one out. PS. Ruby 1.9 does have a native OrderedHash, the same as the one from ActiveSupport.
- nicholaides 16y agoActually, insertion order preservation is a 1.9 feature: > Hashes enumerate their values in the order that the corresponding keys were inserted. from http://www.ruby-doc.org/core/classes/Hash.html http://www.ruby-doc.org/core/classes/Hash.html
- rue 16y agoThe docs were wrong for a long time, but looking back at the issue, there was a quiet turnaround in http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/21856 http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/.... So, hashes can be considered ordered in 1.9. It's a mistake to corrupt the data structure, in my opinion, but apparently that boat has now sailed. Thanks for the prod to recheck and sorry about the outdated info.