This worked, but I feel like it shouldn't have...?


So, I just ran some code in 7.12... it worked, but I don't think it should've.
It wants you to puts each element of each array, but not the arrays themselves.

I entered

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

s.each do |sub_array|
    puts sub_array

And it accepted that.
But I was just entering that to see what happened. I thought the correct code was going to require another ".each" somewhere... But it took that. Can someone explain this to me?


Not sure the exact instructions, however if this code is unmodified from what the exercise gave you then you have encountered a bug. If there is a button to do so in the exercise, please report it.



I did modify it. The lesson only starts with the array s.
But I only added the block at the bottom, and I didn't think that should be enough.
Shall I still report it?


Before you do, can you paste here the exercise instructions? Let's make sure it needs to be reported first.


Puts out every element inside the sub-arrays inside s.

  1. Iterate through .each element in the s array. Call the elements sub_array.
  2. Then iterate through .each sub_array and puts out their items.