From: Brian Candler Date: 2009-08-24T17:50:13+09:00 Subject: Re: 1.8.7 String#lines keeps new-line chars (say it ain't so in 1.9) Thomas Sawyer wrote: > On Aug 23, 3:32�am, Brian Candler wrote: > >> Perhaps most importantly of all, if the newlines were stripped, there >> would be loss of data and it would be impossible to reconstruct the >> original file exactly from the members of the lines array (e.g. >> lines.join), as your example shows nicely. > > How is there loss of data, when you know what was removed? Just join > ("\n"). "Loss of data" means "you don't get back exactly what you started with". Taking your example, I believe that you want both "A\nB\nC" and "A\nB\nC\n" to result in lines ["A","B","C"], so this operation is not reversible. Or did you want "A\nB\nC\n" to result in ["A","B","C",""] ? That would surprise me more. Most inputs have terminating newlines on the final line. -- Posted via http://www.ruby-forum.com/.