Created
June 10, 2013 21:46
-
-
Save chhhris/5752670 to your computer and use it in GitHub Desktop.
This file contains 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
# Create Hashes for the following use-cases. | |
# A movie collection that organizes by genres | |
movies { | |
:genre1 => ["movie title 1", "movie title 2", "movie title 3"], | |
:genre2 => ["movie title 1", "movie title 2", "movie title 3"], | |
:genre3 => ["movie title 1", "movie title 2", "movie title 3"], | |
} | |
} | |
# Recipes with ingredients | |
recipes { | |
:dish1 => ["ingredient 1", "ingredient2", "ingredient3"], | |
:dish2 => ["ingredient 1", "ingredient2", "ingredient3"], | |
:dish3 => ["ingredient 1", "ingredient2", "ingredient3"] | |
} | |
# User profiles where each user has a list of favorite colors along with 3 personal essays, essay_1, essay_2, essay_3 | |
# Just be creative, create a bunch of fake data just for the practice of how you would store this data in a structured hash. | |
# Feel free to create a single file, hashes.rb with a bunch of these and send them to me for review. | |
# There are really no wrong answers - there are just more logical ways of storing this sort of data. | |
# Jimmy / navy blue, green / essay_1, essay_2, essay_3 | |
# Flavia / hot pink, yellow, royal blue / essay_a, essay_b, essay_c | |
# Grantham / red, scarlet, oxblood / essay_1, essay_2, essay_3 | |
# Steny / green / essay_x, essay_y, essay_z | |
user_profiles { | |
:user => [{ :colors => ["fav_color1", "fav_color2"], {:essays => ["essay_1", "essay_2", "essay_3"]}] | |
:Jimmy => [{ :colors => ["navy blue", "green"], {:essays => ["essay_1", "essay_2", "essay_3"]}] | |
:Flavia => [{ :colors => ["hot pink", "yellow", "royal blue"], {:essays => ["essay_a", "essay_b", "essay_c"]}] | |
:Granthan => [{ :colors => ["red", "oxblood"], {:essays => ["essay_x", "essay_y", "essay_z"]}] | |
:Steny => [{ :colors => ["british racing green"], {:essays => ["essay_i", "essay_ii", "essay_iii"]}] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment