On 25 February 2011 17:17, Matt Jones <[email protected]> wrote:
> I've had to build little arrays of single-key hashes like this to work
> around 1.8.6 not having ordered hash semantics.

...or you have a normal hash with one of the values as an array of the
keys in the order you want (I normally call it ":order"). Then when
you want to iterate you hash in order:

my_hash = {:name => "fred", :order => [:age, :foo, :name], :age =>
"21", :foo => "bar"}
my_hash[:order].each do |key|
  puts my_hash[key]
end

Keeps it all "standard" and in one object... YMMV

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to