On 8/21/06, thoran @ thoran. com <thoran / thoran.com> wrote:
> I was surprised to find the following...
>
> irb(main):001:0> {:a => 'a', :b => 'b'}
> => {:a=>"a", :b=>"b"}
[..]
> I then assumed that there might be some kind of optimisation going on,
> but how much optimisation of {:a => 'a', :b => 'b', ... } can there
> be?

Hashes are unordered so that Ruby can use the hash function of the
keys.  Read up on hashes at wikipedia:
http://en.wikipedia.org/wiki/Hash_table

There was a thread about making an "ordered hash" in the last few
weeks.  Worth searching for.

;Daniel

-- 
Daniel Baird
http://tiddlyspot.com (free, effortless TiddlyWiki hosting)
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog ::
Things That Suck)