blob: 46a47d8c9be1d2a87efd1af0532f02b635f58768 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH Path.by_line 3 2025-11-29 "Tomo man-pages"
.SH NAME
Path.by_line \- iterate by line
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI Path.by_line\ :\ func(path:\ Path\ ->\ func(->Text?)?)
.fi
.SH DESCRIPTION
Returns an iterator that can be used to iterate over a file one line at a time, or returns none if the file could not be opened.
.SH ARGUMENTS
.TS
allbox;
lb lb lbx
l l l.
Name Type Description
path Path The path of the file.
.TE
.SH RETURN
An iterator that can be used to get lines from a file one at a time or none if the file couldn't be read.
.SH EXAMPLES
.EX
# Safely handle file not being readable:
if lines := (./file.txt).by_line()
for line in lines
say(line.upper())
else
say("Couldn't read file!")
# Assume the file is readable and error if that's not the case:
for line in (/dev/stdin).by_line()!
say(line.upper())
.EE
.SH SEE ALSO
.BR Tomo-Path (3)
|