Skip to content
FutureBlitz

    Install

    Import std.core.format

    Format

    std.core.format

    function

    Public Function Format(template: String, values: Formattable...): String Throws FormatError

    template with its fields filled: "{}" is the next value, "{0}" the first, and either can take a format spec after a ':', as "{0:>8}" or "{:.2}" does, or else shows its value as "{x}" does; "{{" and "}}" are braces. In source, a template is a raw string, r"{} of {}", whose braces aren't interpolations. Throws a FormatError for a template that isn't one, a field whose value isn't given, or a spec that its value doesn't take.

    Examples

    Local line = Try Format(r"{} has {} points", "Ada", 36)
    Expect(line == "Ada has 36 points")
    Local swapped = Try Format(r"{1}, {0}", "a", "b")
    Expect(swapped == "b, a")
    Local padded = Try Format(r"[{0:>5}]", 42)
    Expect(padded == "[   42]")

    std/core/format.fb, line 47

    Report an issue with this page or with FutureBlitz on GitHub.