Thomas said:
=A0 >> "A\nB\nC".lines.to_a
=A0 =3D> ["A\n", "B\n", "C"]
Please, tell me that's a mishap, and not how 1.9 works. I'd expect:
=A0 >> "A\nB\nC".lines.to_a
=A0 =3D> ["A", "B", "C"]
Why would you expect that? The documentation is very clear.
--------------------------------------------------------------- IO#lines
=A0 =A0 =A0ios.lines(sep=3D$/) =A0 =A0 =3D> anEnumerator
=A0 =A0 =A0ios.lines(limit) =A0 =A0 =A0=3D> anEnumerator
=A0 =A0 =A0ios.lines(sep, limit) =3D> anEnumerator
------------------------------------------------------------------------
=A0 =A0 =A0Returns an enumerator that gives each line in _ios_. The strea= m
=A0 =A0 =A0must be opened for reading or an +IOError+ will be raised.
=A0 =A0 =A0 =A0 f =3D File.new("testfile")
=A0 =A0 =A0 =A0 f.lines.to_a =A0#=3D> ["foo\n", "bar\n"]
=A0 =A0 =A0 =A0 f.rewind
=A0 =A0 =A0 =A0 f.lines.sort =A0#=3D> ["bar\n", "foo\n"]
If it changed in 1.9, that would be another source of incompatibilities.
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.