From: Larry Lv Date: 2011-09-13T23:40:32+09:00 Subject: Re: Iterate Array and (pretty)print --001517478356eef6a404acd39f76 Content-Type: text/plain; charset=ISO-8859-1 hi, u have output @hosts' elements in the block? why would you add a puts in front of it? u can do it just with Array.join *puts hosts.join("\n")* On Tue, Sep 13, 2011 at 10:33 PM, dwight schrute wrote: > Hi, > > I am trying to iterate through an array, convert the output to a string > and puts that string. > > CODE: > > @hosts = ["test1", "test2", "test3", "test4" > puts @hosts.each { |x| print x + "\n" }.to_s > > CURRENT OUTPUT: > > ["test1", "test2", "test3", "test4"] > > DESIRED OUTPUT: > > However, I want this output to go into an email message, so I'm want to > lose the Square brackets and quotes, so it looks like this (and is a > string): > > test1 > test2 > test3 > > Any ideas? > > Thanks. > > Dwight > > -- > Posted via http://www.ruby-forum.com/. > > -- Best Regards, Larry Lv @ Baidu NLP --001517478356eef6a404acd39f76--