My array of arrays exercise - correct behaviour is achieved yet the auto grading part says I did something wrong


#1



So far everything has been going great in the course. I wrote the following code and it worked but there is a message coming up saying that it did not work. This is although I am looking at the correct results in the console.


s = [["ham", "swiss"], ["turkey", "cheddar"], ["roast beef", "gruyere"]]
s.each do |sandwich|
    sandwich.each do |ingredient|
        puts "#{ingredient} "
    end
    puts "\n"
end


#2

Hi try to remove this puts

puts "\n"

I think that puts will print averything on his own line so you don't need of the '\n'


#3

That '\n' actually allows my output to have the contents of each sub array separated from the contents of the next sub- array etc. I changed puts "#{ingredient} " to puts ingredient. That got rid of the error and everything worked perfectly. Thanks so much for the feedback though.


#4

Probably the trailing space.

Usually it's the simplest most obvious interpretation of what the instructions describe, like puts ingredient as you said. The exercise's author has to have anticipated your output and often wasn't being very exhaustive.