From: Adam Prescott Date: 2011-09-14T06:12:12+09:00 Subject: Re: Iterate Array and (pretty)print On Tue, Sep 13, 2011 at 3:33 PM, dwight schrute wrote: > > puts @hosts.each { |x| print x + "\n" }.to_s > Just for completeness since nobody has quite covered it yet, @hosts.each { ... } returns the receiver, which in this case is @hosts, and then you call .to_s on the result. So, closer to the argument actually passed to puts, you essentially have @hosts.to_s which is "[\"test1\", \"test2\", \"test3\", \"test4\"]", which, when puts'd, is ["test1", "test2", "test3", "test4"]. However, in your block you also print, so the real, full output should have been: test1 test2 test3 test4 ["test1", "test2", "test3", "test4"]