From: Jacob Mitchell Date: 2010-07-12T21:35:16+09:00 Subject: Re: Arrays and Hashes --0016e64ec1acfb2471048b2ffb76 Content-Type: text/plain; charset=ISO-8859-1 Arrays have order because each one represents a sequence of objects. This guarantees that for a given array you'll get consistent results using the "each" method: a = [1,2,3] a.each {|n| puts n} #you'll always get 1 2 and 3 in that order Hashes, on the other hand, are more about letting you map some object, the key, to another object, the value. A single hash can have several of these mappings, but the "order" of the mappings is insignificant and therefore not necessarily consistent. {:a => 1, :b => 2, :c => 3} == {:b => 2, :a => 1, :c => 3} # true Although all of the the "each" methods provided by a hash ("each", "each_pair", etc.) return items in a sequence, that sequence isn't guaranteed to be the same every time. Hope that helps. -Jake On Mon, Jul 12, 2010 at 8:22 AM, Abder-rahman Ali < abder.rahman.ali@gmail.com> wrote: > In "Why's poignant guide to Ruby" it mentions the following: > > Unlike arrays, the items in a hash are not kept in a specific order. > > Can you clarify on this? > > Thanks. > -- > Posted via http://www.ruby-forum.com/. > > --0016e64ec1acfb2471048b2ffb76--