WriteBool v0.1.0

Source
Appends true or false to a builder.

Package: Format

Signature

func WriteBool(
    builder: *StringBuilder,
    value: bool8
);

Parameters

NameTypeDescription
builder*StringBuilderThe builder to append to.
valuebool8The value to write.

bool is an alias for bool8, so an ordinary bool reaches this directly. A bool16 or a bool32 has to be narrowed to bool8 on the way in — the wider bools say the same two words, and there is only this one function to say them.

Remarks

Writes the word true or the word false, never 1 or 0. Nothing else is appended around it, and nothing is allocated beyond whatever growth the builder needs.

Example

import Format::WriteBool;
import Text::StringBuilder;

func Main() -> int {
    var builder = StringBuilder::New();
    builder.Append("cached: ");
    WriteBool(@builder, true);

    var line = builder.IntoString(); // "cached: true"

    line.Free();
    return 0;
}

See also