Course of Raku / Objects, I/O, and exceptions / Input and output / File handles / Exercises / Count the lines
Solution: Count the lines
Here is a possible solution to the task.
Code
spurt 'data.txt', "a\nb\nc\nd\n";
say 'data.txt'.IO.lines.elems;🦋 You can find the source code in the file count-lines.raku.
Output
4Comments
.IO.linesreturns the lines of the file as a list..elemscounts them, giving4.