Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2474
| From | Cyril Joe <cyril_jose@ymail.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | newlines in array problem |
| Date | 2011-04-07 11:38 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <030a5c75c68358523471052f22f04f7b@ruby-forum.com> (permalink) |
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?
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Next in thread | Find similar | Unroll thread
newlines in array problem Cyril Joe <cyril_jose@ymail.com> - 2011-04-07 11:38 -0500
Re: newlines in array problem Michel Demazure <michel@demazure.com> - 2011-04-07 11:43 -0500
Re: newlines in array problem Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-04-07 11:50 -0500
Re: newlines in array problem Cyril Jose <cyril_jose@ymail.com> - 2011-04-07 13:08 -0500
Re: newlines in array problem 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-07 13:34 -0500
Re: newlines in array problem Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-04-07 14:17 -0500
Re: newlines in array problem 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-07 18:29 -0500
csiph-web