16/16 Iterating over a hash SOLVED


#1

Okay heres the deal...Im having trouble understanding how to do this..Can anyone help me out? Heres my code....Im probably way off... :confused:

lunch_order = {
"Ryan" => "wonton soup",
"Eric" => "hamburger",
"Jimmy" => "sandwich",
"Sasha" => "salad",
"Cole" => "taco"
}

lunch_order.each { |element| puts element}


#2

Begin by considering how it misbehaves, that may say a lot about which part of the code needs to be adjusted. (Also tells anyone looking to help what they're looking for)


#3

well the error says "It looks like your printing hash keys to the console. Only print the values." I dont know how to do that....


#4

If you're printing both but only want one, then you'll need to separate them in some way right? Where does this happen and what have you got to your disposal in that situation?

You're iterating through a hash using its each method, see if you can make anything out here:
http://docs.ruby-lang.org/en/2.0.0/Hash.html#method-i-each
Which I found by googling "ruby hash each"


#5

Okay, thank you..Got it


#6

If you scroll down a little there's also one specifically for getting just the values


#7

I am very confused! I still get the same error message even when I try incorperating the new things from the website. Please help!


#8

This exercise really kicking my butt .... I checked out that link he provided but it wasn't speaking to me at all. How did you get the program print out just the values ?


#9

If you have a question or error please create a +New Topic with code, lesson and error/question. Thanks