aboutsummaryrefslogtreecommitdiff
path: root/man/man3/tomo-Path.by_line.3
blob: eed871365153ffc9c2816081da2d28e3a022a948 (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
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH Path.by_line 3 2025-04-30 "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 lb
l l l l.
Name	Type	Description	Default
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