From: Xiao Jia Date: 2010-03-10T15:22:49+09:00 Subject: Re: hash An iterator is an object that allows a programmer to traverse through all the elements of a collection, regardless of its specific implementation. In object-oriented programming, the Iterator pattern is a design pattern in which iterators are used to access the elements of an aggregate object sequentially without exposing its underlying representation. So the order in which you can access the elements in the collection is predefined by the underlying implementation. It is only guaranteed that elements can not be skipped or that a previously visited element can not be accessed a second time. But the order differs because of different implementation. 2010/3/10 Dhananjay Bhavsar : > Hello >  the code is like this > hash_fruit = {} > hash_fruit ['mango']='orange' > hash_fruit ['banana']='yellow' > hash_fruit ['grapes']='green' > hash_fruit ['apple'] = 'red' > hash_fruit .each do |key , value | > puts key + '  '+value >  end > > and the answer is > apple red > banana yellow > mango orange > grapes green > > why is it so? > -- > Posted via http://www.ruby-forum.com/. > >