Skip to content

Instantly share code, notes, and snippets.

@bagwanpankaj
Created January 30, 2011 17:25
Show Gist options
  • Save bagwanpankaj/803031 to your computer and use it in GitHub Desktop.
Save bagwanpankaj/803031 to your computer and use it in GitHub Desktop.
Changes in Ruby 1.9
#Hash becomes more compatible
#Do you know you can write hash in ruby like you do in other languages.
hs = {first: 1, second: 2, third: 3, fourth: 4}
# => {:first=>1, :second=>2, :third=>3, :fourth=>4}
hs.class
# => Hash
#In Ruby 1.9 hash became ordered. Don't you believe try it yourself
hs = {:first=>1, :second=>2, :third=>3, :fourth=>4}
#OUTPUT in Ruby 1.9
# => {:first=>1, :second=>2, :third=>3, :fourth=>4}
#ain't they ordered hah
#OUTPUT in Ruby 1.8
#=> {:fourth=>4, :first=>1, :second=>2, :third=>3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment