Created
October 1, 2013 12:02
-
-
Save gregeng/6777421 to your computer and use it in GitHub Desktop.
Lab 1: Hashes Reverse Each Word
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
# A movie collection that organizes by genres | |
# Recipes with ingredients | |
# User profiles where each user has a list of favorite colors along with 3 personal essays, essay_1, essay_2, essay_3 | |
## Hashes | |
movie_collection = { | |
:action => ["Man on Fire", "Fight Club"] | |
:adventure => ["National Treasure", "National Treasure 2"] | |
:comedy => ["BASEketball", "Wedding Crashers"] | |
:drama => ["Schindler's List", "Enemy at the Gates"] | |
:dramedy => "Garden State" | |
:horror => ["Exorcist", "The Sixth Sense"] | |
} | |
recipes = { | |
:lasagna => ["pasta", "tomato sauce", "cheese", "ground beef"] | |
:pizza => ["dough", "tomato sauce", "cheese"] | |
:sushi => ["seaweed", "rice", "salmon", "cucumber", "avocado"] | |
:tacos => ["corn tortillas", "pork", "cilantro", "onions"] | |
} | |
user_profiles = { | |
:greg => | |
[ | |
"favorite colors" =["red","blue","green"] | |
"personal_essays" =["essay_1", "essay_2", "essay_3"] | |
] | |
:dave => | |
[ | |
"favorite colors" =["maroon","shale","lavendar"] | |
"personal_essays" =["essay_1", "essay_2", "essay_3"] | |
:kyle => | |
[ | |
"favorite colors" =["brown","neon green"] | |
"personal_essays" =["essay_1", "essay_2", "essay_3"] | |
] | |
} | |
#################################### | |
# Reverse Each Word | |
def rev_sentence(sentence="this sentence is backwards") | |
sentence.reverse! | |
array = sentence.split(" ") | |
array.reverse! | |
puts array.join(" ") | |
end | |
rev_sentence | |
#################################### | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment