Someone explain me about why this code run? 12/16


My first code was;

s = [[“ham”, “swiss”], [“turkey”, “cheddar”], [“roast beef”, “gruyere”]]

s.each { |x| puts x }

and it runs, I don’t know why? I just think out what would be the code should I put and that’s the code I get of my first think.

But when I look at the “Hint” the code was different to mine.I’m confuse about this but it prints output the same thing.

Enlightened me! :Dgrin: Thanks a lot


The code you provided runs because there isn’t anything wrong with it.
It just goes through each item and prints it out. Very simple.

If you provide the code in the hint here, then I can compare the two snippets for you if you’d like.


Well, could you? if you dont mind. :slight_smile: Thanks a lot. I really want to know and learn everything before I proceed to the next exercise.