[Ruby] hash key order

Ryan Davis ryand-ruby at zenspider.com
Fri Feb 23 10:54:00 PST 2007


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.




More information about the Ruby mailing list