Created
January 28, 2013 03:42
-
-
Save yangsu/4652840 to your computer and use it in GitHub Desktop.
Ruby Hashes
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
| # Literal Form | |
| numbers = { 1 => 'one', 2 => 'two' } | |
| # => {1=>"one", 2=>"two"} | |
| # Accessing element using key | |
| numbers[1] # => "one" | |
| # Can use symbols as keys | |
| stuff = { :array => [1, 2, 3], :string => 'Hello' } | |
| # => {:array=>[1, 2, 3], :string=>"Hello"} | |
| # Accessing element using key | |
| stuff[:string] # => "Hello" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment