Skip to content

Instantly share code, notes, and snippets.

@gabebw
Created June 26, 2014 21:26
Show Gist options
  • Save gabebw/fa667936cf07ff6e2658 to your computer and use it in GitHub Desktop.
Save gabebw/fa667936cf07ff6e2658 to your computer and use it in GitHub Desktop.
All about Ruby hashes

Ruby Hashes

  • Represents a key-value mapping
  • Contains zero or more key/value pairs
  • Can only access values by referencing keys

Exercises

How do you get "Gabe" out of the following hash?

hash = { "name" => "Gabe" }

How do you get "There" out of the following hash?

hash = { "hello" => "There" }

How do you get { "name" => "Gabe" } out of the following hash?

hash = { "hello" => { "name" => "Gabe" } }

How do you get "Gabe" out of the following hash?

hash = { "hello" => { "name" => "Gabe" } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment