From: "Jesús Gabriel y Galán" Date: 2011-04-08T01:50:21+09:00 Subject: Re: newlines in array problem On Thu, Apr 7, 2011 at 6:38 PM, Cyril Joe wrote: > Is there a way to get rid of newlines in an array? > Example: array = ["hel\nlo", "bl\nah"] > > I want the output to be new_array = ["hello", "blah"] > > I tried: > > array.each do |el| >  el.delete("\n") > end > > But that didn't work. Can't figure this out. Any suggestions? String#delete returns a copy of the string, it doesn't modify it in place. Use String#delete! ruby-1.8.7-p334 :017 > array = ["hel\nlo", "bl\nah"] => ["hel\nlo", "bl\nah"] ruby-1.8.7-p334 :018 > array.each {|word| word.delete!("\n")} => ["hello", "blah"] ruby-1.8.7-p334 :019 > array => ["hello", "blah"] Jesus.