Skip to content

Instantly share code, notes, and snippets.

@surrealdetective
Created June 10, 2013 22:16
Show Gist options
  • Save surrealdetective/5752909 to your computer and use it in GitHub Desktop.
Save surrealdetective/5752909 to your computer and use it in GitHub Desktop.
hash practice
# Create Hashes for the following use-cases.
# A movie collection that organizes by genres
movie_genre = {
:anime => ['The Girl Who Leapt Through Time', "Akira"],
:comedy => ['Bernie', 'Zoolander'],
:action => ['The Matrix']
}
# Recipes with ingredients
recipes = {
:avocado => {
:ingredients => ['avocado', 'cayenne pepper', 'salt', 'pepper'],
:instructions => ['cut', 'place', 'season']
},
:shake => {
:ingredients => ['strawberry', 'banana'],
:instructions => ['blend']
},
:salad => {
:ingredients => ['salt', 'kale', 'apple', 'carrot', 'walnut'],
:instructions => ['mix']
}
}
# User profiles where each user has a list of favorite colors along with 3 personal essays, essay_1, essay_2, essay_3
user_profile = {
:alex => {
:favorite_colors => ['red', 'black', 'orange'],
:essay_1 => 'I rule',
:essay_2 => "What's up!",
:essay_3 => 'Everything!!'
},
:dan => {
:favorite_colors => ['purple', 'yellow'],
:essay_1 => 'I love design',
:essay_2 => 'I love nyc',
:essay_3 => 'I love marie'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment