15 May 18:21
Access Hash in the same order that was created
From: Mario Ruiz <mario <at> betware.com>
Subject: Access Hash in the same order that was created
Newsgroups: gmane.comp.lang.ruby.general
Date: 2008-05-15 16:22:56 GMT
Subject: Access Hash in the same order that was created
Newsgroups: gmane.comp.lang.ruby.general
Date: 2008-05-15 16:22:56 GMT
I need to access to a Hash in the same order that It was created:
mh=Hash.new()
mh["one"]="1"
mh["two"]="2"
mh["three"]="3"
mh["four"]="4"
mh.each {|val|
puts val[0]
}
In this example I get:
three
two
one
four
and I would like to get:
one
two
three
four
is that possible?
Thanks
--
--
Posted via http://www.ruby-forum.com/.
(Continue reading)
RSS Feed