From: Abder-rahman Ali Date: 2010-07-13T00:43:01+09:00 Subject: Re: Arrays and Hashes Gavin Kistner wrote: > On Jul 12, 6:22�am, Abder-rahman Ali > wrote: >> Unlike arrays, the items in a hash are not kept in a specific order. > > Note that this is no longer true in Ruby 1.9. Insertion order, > including initialization, is maintained for Hashes: > > > Slim2:~ phrogz$ irb --simple-prompt >>> h = { a:1, z:7 } > => {:a=>1, :z=>7} >>> h[:f] = 14; h[:b] = 99 > => 99 >>> h['last'] = "this one" > => "this one" >>> h[-1] = "really last" > => "really last" >>> h.each{ |k,v| p [k,v] } > [:a, 1] > [:z, 7] > [:f, 14] > [:b, 99] > ["last", "this one"] > [-1, "really last"] > => {:a=>1, :z=>7, :f=>14, :b=>99, "last"=>"this one", -1=>"really > last"} >>> h.keys > => [:a, :z, :f, :b, "last", -1] Thanks a lot Gavin. I may not getting your point clear. What is it not applicable to Ruby 1.9 from what Jake said? -- Posted via http://www.ruby-forum.com/.