There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
Hello, I tried this not very smart solution to iterate over the hash. though I thought the syntax was ok, actually nothing is written on the console. Could you explain me why?
lunch_order.each { |element| element.each { |x, y| puts y }}
|element| is assigned each element of the lunch_order hash in turn, so the first value assigned is ["Ryan", "wonton soup"]. Then when you use element.each, you take these values: ["Ryan", "wonton soup"] one at a time in turn, so x gets assigned "Ryan" and y gets nothing. Then in the next iteration of this nested .each, x gets assigned "wonton soup" and y again gets nothing. Then control passes back to the first .each, and the whole process repeats with ["Eric", "hamburger"], etc.