Created
January 30, 2011 17:25
-
-
Save bagwanpankaj/803031 to your computer and use it in GitHub Desktop.
Changes in Ruby 1.9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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