Skip to content

Instantly share code, notes, and snippets.

@KamilLelonek
Last active August 29, 2015 14:10
Show Gist options
  • Save KamilLelonek/cd04b40ab50bb2bf95df to your computer and use it in GitHub Desktop.
Save KamilLelonek/cd04b40ab50bb2bf95df to your computer and use it in GitHub Desktop.
Ruby hash quirks - part 1
[1] (pry) main: 0> my_hash = Hash.new []
=> {}
[2] (pry) main: 0> my_hash[:hobbies] << 'dancing';
[3] (pry) main: 0> my_hash[:hobbies] << 'swimming';
[4] (pry) main: 0> my_hash[:skills] << 'java';
[5] (pry) main: 0> my_hash[:skills] << 'php';
[6] (pry) main: 0> my_hash[:skills]
=> ["dancing", "swimming", "java", "php"]
[7] (pry) main: 0> my_hash[:some_random_key]
=> ["dancing", "swimming", "java", "php"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment