From: Phrogz Date: 2010-07-12T22:15:22+09:00 Subject: Re: Arrays and Hashes 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]