Skip to content

Modern Math TryParseLong

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Math Library › Math Library › TryParseLong

TryParseLong

Parses a whole string as a Long, returning an empty Optional if invalid or too big.

Syntax

TryParseLong( s )

Examples

#import "std/numeric"
using numeric

var r = TryParseLong( "42" )
print r.HasValue( )          '' true
print r.Value( )             '' 42

'' RANGE IS CHECKED: a value too big for the type is absent, not wrapped
print TryParseLong( "99999999999999" ).HasValue( )        '' false
print TryParseLong( "1.5" ).HasValue( )                    '' false -- not an integer

Library: Math Library
Category: Math Library
Documented under: Nothing Becomes A Keyword

Clone this wiki locally