Time to practice. I'm going to give you two arrays.
chocolate = ["Ritual",
"Chuao",
"Chocolove",
"Scharffen Berger"]
peanut_butter = ["Peter Pan",
"Skippy",
"Justin's",
"Smucker's",
"Crazy Richard's"]
I want you to zip them and then print out to the screen,
"You got your Ritual in my Peter Pan!"
"You got your Peter Pan in my Ritual!"
"You got your Chuao in my Skippy!"
Now let's practice again with some real world data
. This is something that
you'll often get. Someone writes some pretty poor software, and you get two
associated arrays, but you need to actually put it together.
People are the worst.
We have two arrays from a form.
people = ["Hannah",
"Penelope",
"Rabastan",
"Neville",
"Tonks",
"Seamus"]
houses = ["Hufflepuff",
"Ravenclaw",
"Slytherin",
"Gryffindor",
"Hufflepuff",
"Gryffindor"]
Some jerk left us with two arrays. Take the next few minutes to put them together and then I would like you to print them out to the screen in this kind of format:
"Hannah is in Hufflepuff."
"Penelope is in Ravenclaw."
people.zip(houses).each do |name, house|
puts "#{name} is in #{house}
end
And so forth.