Skip to content

Instantly share code, notes, and snippets.

@ParkinT
Created March 10, 2011 01:37
Show Gist options
  • Save ParkinT/863412 to your computer and use it in GitHub Desktop.
Save ParkinT/863412 to your computer and use it in GitHub Desktop.
I would expect the 'key' only in the second case
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