main
Download
40 lines 899 BGroffModified 2025-11-29 raw
12345678910111213141516171819202122232425262728293031323334353637383940
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH Text.to 3 2025-11-29 "Tomo man-pages"
.SH NAME
Text.to \- slice to an end index
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI Text.to\ :\ func(text:\ Text,\ last:\ Int\ ->\ Text)
.fi
.SH DESCRIPTION
Get a slice of the text, ending at the given position.


.SH ARGUMENTS

.TS
allbox;
lb lb lbx
l l l.
Name	Type	Description
text	Text	The text to be sliced. 
last	Int	The index of the last grapheme cluster to include (1-indexed). 
.TE
.SH RETURN
The text up to and including the given grapheme cluster.

.SH NOTES
A negative index counts backwards from the end of the text, so `-1` refers to the last cluster, `-2` the second-to-last, etc. Slice ranges will be truncated to the length of the text.

.SH EXAMPLES
.EX
assert "goodbye".to(3) == "goo"
assert "goodbye".to(-2) == "goodby"
.EE
.SH SEE ALSO
.BR Tomo-Text (3)