Hi all,
Do hashes maintain insertion order in JRuby 1.1? I would like to take a
JRuby hash to a Java LinkedHashMap and maintain insertion order
throughout.
Thanks,
Barbara
Hi all,
Do hashes maintain insertion order in JRuby 1.1? I would like to take a
JRuby hash to a Java LinkedHashMap and maintain insertion order
throughout.
Thanks,
Barbara
Hi there. It appears that it (JRuby 1.1.2) does maintain insertion
order, but that is different from MRI (1.8.6-p111).
$ jirb
irb(main):001:0> h={:a=>1,:b=>2}; h.delete(:a); h[:a]=3; h.keys
=> [:b, :a]
$ irb
irb(main):001:0> h={:a=>1,:b=>2}; h.delete(:a); h[:a]=3; h.keys
=> [:a, :b]
Hirotsugu A. wrote:
Hi there. It appears that it (JRuby 1.1.2) does maintain insertion
order, but that is different from MRI (1.8.6-p111).$ jirb
irb(main):001:0> h={:a=>1,:b=>2}; h.delete(:a); h[:a]=3; h.keys
=> [:b, :a]
Note that 1.8.6 does not maintain insertion ordering in any way. JRuby
maintains exact insertion ordering, where deleted keys re-set will show
up later in the sequence.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
However, Ruby 1.9 preserves hash ordering, so maybe this isn’t such a
bad thing.
Joshua
On 14-Jun-08, at 10:57 AM, Hirotsugu A. wrote:
JRuby maintains exact insertion ordering, where deleted keys re-set
To unsubscribe from this list, please visit:
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
Joshua H. wrote:
However, Ruby 1.9 preserves hash ordering, so maybe this isn’t such a
bad thing.
On 14-Jun-08, at 10:57 AM, Hirotsugu A. wrote:
Right. And I think it is a bad idea to write code that relies on
JRuby’s (current) insertion-order-preserving behavior.
It’s probably not such a bad idea…it’s specified behavior now in Ruby
1.9 that insertion order is preserved for operations where it makes
sense (like keys, each, etc). It was specifically added.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
On Jun 14, 2008, at 1:45 AM, Charles Oliver N. wrote:
- Charlie
Right. And I think it is a bad idea to write code that relies on
JRuby’s (current) insertion-order-preserving behavior.
Hiro
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
On Jun 14, 2008, at 1:17 PM, Charles Oliver N. wrote:
makes sense (like keys, each, etc). It was specifically added.
- Charlie
Thank you both Joshua and Charlie for clarifying this.
Hiro
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
View this message in context:
http://www.nabble.com/Is-hash-ordered-in-JRuby-1.1--tp17803193p17860193.html
Sent from the JRuby - User mailing list archive at Nabble.com.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs