[Ruby] hash key order
Fruchterman, Thomas
tfrucht at amazon.com
Fri Feb 23 12:05:51 PST 2007
It's easy to write an Ordered Hash. There is a "calculations" plugin that includes one.
http://wiki.rubyonrails.org/rails/pages/Calculations+Plugin
-----Original Message-----
From: ruby-bounces at zenspider.com [mailto:ruby-bounces at zenspider.com] On Behalf Of Ryan Davis
Sent: Friday, February 23, 2007 10:54 AM
To: Seattle Ruby Brigade!
Subject: Re: [Ruby] hash key order
On Feb 23, 2007, at 1:40 PM, ben wiseley wrote:
> Can you depend on the order of keys in a hash in Ruby?
>
> Example:
> h = {:one => "one", :two => "two"}
>
> Will h.keys.first always be :one or can't you depend on that?
Hashes are unordered collections. You can't depend on the order of the contents at all.
_______________________________________________
Ruby at zenspider.com - Seattle.rb non-commercial list http://www.zenspider.com/seattle.rb
http://www.zenspider.com/mailman/listinfo/ruby
More information about the Ruby
mailing list