IsEmpty v0.1.0

Source
Reports whether anything has been written.

Package: Text

Signature

func IsEmpty(self) -> bool;

Returns

true when Length is 0.

It says nothing about the Capacity: a builder that has been Cleared is empty but still holds its block, and so is one built with WithCapacity that has not been appended to.

Example

import Text::StringBuilder;

func Main() -> int {
    var builder = StringBuilder::WithCapacity(64);
    builder.IsEmpty();  // true -- room reserved, nothing written

    builder.Append("Rux");
    builder.IsEmpty();  // false

    builder.Clear();
    builder.IsEmpty();  // true, and the 64 bytes are still there

    builder.Free();
    return 0;
}

See also

  • StringBuilder — the builder type
  • Length — the byte count this tests against zero
  • Clear — empty the builder without releasing the block