From: Stephen Bannasch Date: 2009-08-23T23:05:14+09:00 Subject: Re: 1.8.7 String#lines keeps new-line chars (say it ain't so in 1.9) At 9:58 PM +0900 8/23/09, David A. Black wrote: >Hi -- > >On Sun, 23 Aug 2009, Intransition wrote: > >>Ruby 1.8.7 p72 >> >> >> "A\nB\nC".lines.to_a >> => ["A\n", "B\n", "C"] >> >>Please, tell me that's a mishap, and not how 1.9 works. I'd expect: >> >> >> "A\nB\nC".lines.to_a >> => ["A", "B", "C"] > >String#lines is essentially the same as String#each, which is gone in >1.9. You get, instead of #each and friends (Enumerable), a whole >toolkit of ways to enumerate through strings: > > * lines > * bytes > * chars > * codepoints > >There's no auto-chomping, but there never has been in any string >operation I can think of. It isn't the same but in many places where I might use String#lines I'd use code like this in Ruby 1.8.6: >> "first line\nsecond line\nthird line".split("\n") => ["first line", "second line", "third line"]