Skip to content

fmt

fmt

There is no shipped stdlib/fmt.tg module today. Formatting is currently handled through std.string.

Current status

ItemStatus
stdlib/fmt.tg filenot present
template formatting APInot present
numeric base formatting helpersnot present

Current replacements

Current APISignatureUse
string.from_intfunc from_int(value: i32) -> strinteger formatting
string.from_f64func from_f64(value: f64) -> strfloating formatting
string.from_boolfunc from_bool(value: bool) -> strboolean formatting
string.concatfunc concat(left: str, right: str) -> strstring assembly
string.pad_leftfunc pad_left(value: str, width: i32, ch: str) -> strleft padding
string.pad_rightfunc pad_right(value: str, width: i32, ch: str) -> strright padding

Examples

import std.string as string
func main():
println(string.from_int(42))
import std.string as string
func main():
let label = string.concat("answer=", string.from_int(42))
println(label)
import std.string as string
func main():
println(string.pad_left("7", 3, "0"))
println(string.pad_right("tg", 4, "."))