On Friday 09 December 2005 05:57 am, Ross Bamford wrote:
> Hi,
>
> I have a couple more questions. Hopefully they're not so dumb this time.
>
> 1) I need a hash that maintains insertion order. In Java, I'd use
> LinkedHashMap. Does Ruby have one?

I've only done Ruby for 9 days now, but from the reading I've done, no. It 
would be easy enough to insert the key in an array at the same time you 
insert the key=>value in a hash. You could even make a class that does it all 
for you.

Perhaps there's a better way, but that's one I'm sure would work.

By the way, why do you need initial insertion order? Do you ever need to look 
up by the key value? If not, why not use an array of hashes, or an array of 2 
element arrays?

SteveT
 
Steve Litt
http://www.troubleshooters.com
slitt / troubleshooters.com