You need to look for the method Array#join
, as three_mcwords.join(" ")
. But you called Array#each
, which return the receiver (as per the MRI implementation), on which you called the method #each
.
You called three_mcwords.each do |word|..
. See here the receiver is three_mcwords
, which holds the reference of the array ["if", "the", "printed"]
, thus when each
block competed, you got the array ["if", "the", "printed"]
back.
Example :
['foo', 'bar'].each { |str| "hi" + str } # => ["foo", "bar"]
['foo', 'bar'].join(" ") # => "foo bar"
Both are working as they were implemented in MRI.