(1) Create a hash with the following key value pairs
key | value |
---|---|
red | green |
yellow | purple |
blue | orange |
# your code here
(2) Change values in a hash.
Go from:
lemurs = {
andrew: "for all intensive purposes",
matt: "for all in tents and porpoises"
}
To:
{andrew: 'i am a lemur!', matt: 'i am a lemur, also'}
You do not need to use iteration here.
# your code here
(3)
Go from:
ramen_places = {
'Mu Ramen' => '917-868-8903',
'Ivan Ramen' => '212-582-7940',
'Takashi' => '212-414-2929',
}
To:
Mu Ramen's phone number is 917-868-8903.
Ivan Ramen's phone number is 917-868-8903.
Takashi's phone number is 917-868-8903.
# put your code here
(4) Go from:
lyrics = {
"boy" => "love",
"you're" => "you",
"going" => "take",
"to" => "equals",
"carry" => "love",
"that" => "you",
"weight" => "make"
}
To:
["boy", "you're", "going", "to", "carry", "that", "weight"]
# put your code here
(5)
To:
["love", "you", "take", "equals", "love", "you", "make"]
# put your code here
(6)
What will be the return value of the following expression. Attempt to answer without running this code.
hash = Hash.new
if hash[:thing]
"The thing exists"
else
"The thing does not exist"
end
# put your answer here
(7) What will be the return value of the following expression. Attempt to answer without running this code.
hash = Hash.new("gluten")
if hash[:food]
"this probably has gluten in it, doesn't it?"
else
"what even is a gluten?"
end
# put your answer here