Questionable Answer


#1

I was going through this one and I'm not sure if there was a change to Ruby or not, but the following worked:

s = [["ham", "swiss"], ["turkey", "cheddar"], ["roast beef", "gruyere"]]
s.each { |sub_array| puts sub_array }

I didn't have to go through the way that was hinted at by using nested .each. I'm just not sure why it worked. My best guess is that the .each went ahead and told it to look through the arrays and their inner arrays. Does anyone actually know why?


#2

Yes I hear you, this puzzled me too.