aboutsummaryrefslogtreecommitdiff
path: root/man/man3/tomo-Text.by_line.3
blob: 6f28263b2b595b330943bbc0124850f34925be91 (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 Text.by_line 3 2025-04-30 "Tomo man-pages"
.SH NAME
Text.by_line \- iterate by line
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI Text.by_line\ :\ func(text:\ Text\ ->\ func(->Text?))
.fi
.SH DESCRIPTION
Returns an iterator function that can be used to iterate over the lines in a text.


.SH ARGUMENTS

.TS
allbox;
lb lb lbx lb
l l l l.
Name	Type	Description	Default
text	Text	The text to be iterated over, line by line. 	-
.TE
.SH RETURN
An iterator function that returns one line at a time, until it runs out and returns `none`.

.SH NOTES
This function ignores a trailing newline if there is one. If you don't want this behavior, use `text.by_split($/{1 nl}/)` instead.

.SH EXAMPLES
.EX
text := "
line one
line two
"
for line in text.by_line()
# Prints: "line one" then "line two":
say(line)
.EE