TAKAHASHI Masayoshi wrote:
> Hi,
> 
> Joseph McDonald <joe / vpop.net> wrote:
> >   Has anyone implemented an OrderedHash in ruby?  That is:
> >   Hash.each { } will return items in the order that they were
> >   inserted.  Just want to avoid re-inventing the wheel.


You can also use Array#assoc to implement an ordered hash.
But I assume it's very slow compared to a real hash.

An example:

  h = []

  h << ["key", "value"]
  h << ["a",   2]

Now to get a value out of the array:

  h.assoc("key")[1]   # =>  value


Regards,

  Michael


-- 
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de