Skip to content

convert

convert

There is no separate stdlib/convert.tg module in the current repository. Conversion helpers live in std.string.

Current status

ItemStatus
stdlib/convert.tg filenot present
dedicated conversion modulenot present

Current conversion APIs

NameSignatureDescription
string.from_intfunc from_int(value: i32) -> stri32 to str
string.to_intfunc to_int(value: str) -> i32str to i32
string.from_f64func from_f64(value: f64) -> strf64 to str
string.to_f64func to_f64(value: str) -> f64str to f64
string.from_boolfunc from_bool(value: bool) -> strbool to str
string.to_boolfunc to_bool(value: str) -> boolstr to bool

Examples

import std.string as string
func main():
let text = string.from_int(42)
println(text)
import std.string as string
func main() -> i32:
let value = string.to_int("42")
return value - 42
import std.string as string
func main():
println(string.from_f64(string.to_f64("3.5")))
println(string.from_bool(string.to_bool("true")))