Created
March 10, 2011 01:37
-
-
Save ParkinT/863412 to your computer and use it in GitHub Desktop.
I would expect the 'key' only in the second case
This file contains hidden or 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
Try this in the IRB console. | |
>> testhash = { :key1 => 'val1', :key2 => 'val2', :key3 => 'val3' } | |
>> testhash.each { | key, value | p key.to_s } | |
>> testhash.each { | key | p key.to_s } | |
My expectation was for the output to be the same in both cases. | |
Why the difference? | |
Why are the key and value concatenated? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment