From: Trans Date: 2008-10-02T04:00:30+09:00 Subject: Re: Ordered hash hack for < ruby 1.9? On Oct 1, 2:12 pm, Ben Johnson wrote: > Luis Parravicini wrote: > > On Wed, Oct 1, 2008 at 3:00 PM, Ben Johnson > > wrote: > >> Is there anything out there that does this? Thanks for your help. > > Hash's == method compares if two hashes are equal ( > >http://www.ruby-doc.org/core/classes/Hash.html#M002875) > > > Bye > > I realize that. My class is creating a hash of complex objects. For me > to create the hash by hand would take a long time and be a huge pain in > the ass. Plus this method does other things with the hash, and > ultimately returns a string. I want to test this method and it's > impossible since ruby iterates over a hash in a random order. Since a hash is an unordered collection, one should not test it according to any order. Instead test to see if a key is present and it has certain values. That you want it ordered should raise a red flag for you. T.