4 ms·
Out of curiosity (haven't done ruby for awhile): is your line-by-line implementation safe? Is it guaranteed that the lines are identical in the output file besi
by kyberias 11y ago
Out of curiosity (haven't done ruby for awhile): is your line-by-line implementation safe? Is it guaranteed that the lines are identical in the output file besides the character you're replacing? I'm thinking different CR+LR combinations. What if the final line is not terminated by newline? Doesn't print always add it?
- TheDong 11y agoYou're thinking of 'puts' which appends a newline. 'print' does not The code does handle/preserve all the cases you mentioned (\r\n, final or no final terminating newline, etc).