Skip to content

Instantly share code, notes, and snippets.

@Farzy
Created February 5, 2009 23:03
Show Gist options
  • Save Farzy/59081 to your computer and use it in GitHub Desktop.
Save Farzy/59081 to your computer and use it in GitHub Desktop.
Comparing Ruby 1.8 and Ruby 1.9's hash ordering
% irb1.8
>> h = Hash.new
=> {}
>> 10.times { |i| h[i] = i*10 }
=> 10
>> h
=> {5=>50, 0=>0, 6=>60, 1=>10, 7=>70, 2=>20, 8=>80, 3=>30, 9=>90, 4=>40}
% irb1.9
>> h = Hash.new
=> {}
>> 10.times { |i| h[i] = i*10 }
=> 10
>> h
=> {0=>0, 1=>10, 2=>20, 3=>30, 4=>40, 5=>50, 6=>60, 7=>70, 8=>80, 9=>90}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment