Created
March 20, 2011 02:33
-
-
Save langsharpe/878005 to your computer and use it in GitHub Desktop.
Why are these two lines producing opposite outputs?
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
irb(main):072:0> {"a" => 0.1, "b" => 0.9}.each { |key,value| puts "#{key} is #{value}" } | |
a is 0.1 | |
b is 0.9 | |
=> {"a"=>0.1, "b"=>0.9} | |
irb(main):073:0> {:a => 0.1, :b => 0.9}.each { |key,value| puts "#{key} is #{value}" } | |
b is 0.9 | |
a is 0.1 | |
=> {:b=>0.9, :a=>0.1} |
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
# Put more simply | |
irb(main):074:0> {:a => 0.1, :b => 0.9} | |
=> {:b=>0.9, :a=>0.1} | |
irb(main):075:0> {"a" => 0.1, "b" => 0.9} | |
=> {"a"=>0.1, "b"=>0.9} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment