(51 lines)
1 '\" t2 .\" Copyright (c) 2026 Bruce Hill3 .\" All rights reserved.4 .\"5 .TH Int.parse 3 2026-03-08 "Tomo man-pages"6 .SH NAME7 Int.parse \- convert text to integer8 .SH LIBRARY9 Tomo Standard Library10 .SH SYNOPSIS11 .nf12 .BI Int.parse\ :\ func(text:\ Text,\ base:\ Int?\ =\ none,\ remainder:\ &Text?\ =\ none\ ->\ Int?)13 .fi14 .SH DESCRIPTION15 Converts a text representation of an integer into an integer.18 .SH ARGUMENTS20 .TS21 allbox;22 lb lb lbx lb23 l l l l.24 Name Type Description Default25 text Text The text containing the integer. -26 base Int? The numeric base to use when parsing the integer. If unspecified, the integer's base will be inferred from the text prefix. After any "+" or "-" sign, if the text begins with "0x", the base will be assumed to be 16, "0o" will assume base 8, "0b" will assume base 2, otherwise the base will be assumed to be 10. none27 remainder &Text? If non-none, this argument will be set to the remainder of the text after the matching part. If none, parsing will only succeed if the entire text matches. none28 .TE29 .SH RETURN30 The integer represented by the text. If the given text contains a value outside of the representable range or if the entire text can't be parsed as an integer, `none` will be returned.32 .SH EXAMPLES33 .EX34 assert Int.parse("123") == 12335 assert Int.parse("0xFF") == 25536 assert Int.parse("123xyz") == none37 remainder : Text38 assert Int.parse("123xyz", remainder=&remainder) == 12339 assert remainder == "xyz"41 # Can't parse:42 assert Int.parse("asdf") == none44 # Outside valid range:45 assert Int8.parse("9999999") == none47 # Explicitly specifying base:48 assert Int.parse("10", base=16) == 1649 .EE50 .SH SEE ALSO51 .BR Tomo-Int (3)