Open badetitou opened 3 years ago
I believe there were discussion about this in the past. I also thinks this could be dangerous to change.
On macOS/Linux I can do:
$ cat > /tmp/lines.txt
one
two
three
$ wc -l /tmp/lines.txt
3 /tmp/lines.txt
$ hexdump -c lines.txt
0000000 o n e \n t w o \n t h r e e \n f o
0000010 u r \n f i v e \n s i x \n
000001c
In other words this is considered to be 3 lines, just like in Pharo
'one
two
three' lines "#('one' 'two' 'three')"
I see no reason to change this.
I does of course depend of the definition of 'line', i.e. whether an EOL ends a line or separates 2 lines.
Ok, I understand it can be the intended behavior.
If so, I would love to have a little comment in the lines
method and a test that presents the choice made.
Something like:
testLineCount
| sampleCRString sampleLFString sampleCRLFString sampleCRLFString2 |
sampleCRString := 'Fred', String cr, 'the', String cr, 'Bear'.
sampleLFString := 'Fred', String lf, 'the', String lf, 'Bear'.
sampleCRLFString := 'Fred', String crlf, 'the', String crlf, 'Bear'.
sampleCRLFString2 := 'Fred', String crlf, 'the', String crlf, 'Bear', String crlf.
self assert: sampleCRString lineCount equals: 3.
self assert: sampleLFString lineCount equals: 3.
self assert: sampleCRLFString lineCount equals: 3.
self assert: sampleCRLFString2 lineCount equals: 3.
OK
Bug description The method
lines
does not return the last empty line of a String. But, an empty line is a lineTo Reproduce Steps to reproduce the behavior:
Execute
Expected behavior The last line should be present in the array as an empty line.
Example:
Screenshots If applicable, add screenshots to help explain your problem.
Version information:
Expected development cost
low