baml.Bool

A boolean value — either `true` or `false`.

Reference version

Signature

class baml.Bool

A boolean value — either true or false.

Source:<builtin>/baml/bool.bamlbytes 50–502

Static methods

function

random

(rng: baml.random.Rng = …) -> bool throws never

Returns a random true or false, drawn from rng.

rng defaults to random.SystemRandom, the host's cryptographic entropy source; pass a seeded generator to make the draw reproducible. Each call consumes one byte of entropy and tests its high bit.

Implementations

baml.Concrete for T

Source:<builtin>/baml/core.bamlbytes 747–779

baml.ops.Compare for bool

Instance methods

function

clamp

(self, min: Self, max: Self) -> Self throws never

Clamps self into the range [min, max].

Callers should pass min <= max; if min > max the result is always min, because the lower clamp runs after the upper one. Written as the min/max chain rather than a three-way match so it agrees with int.clamp / float.clamp on that degenerate input too.

function

ge

(self, other: Self) -> bool throws never

Whether self orders after other or equals it. Defaults to self.cmp(other) != Ordering.Less.

function

gt

(self, other: Self) -> bool throws never

Whether self orders strictly after other. Defaults to self.cmp(other) == Ordering.Greater.

function

le

(self, other: Self) -> bool throws never

Whether self orders before other or equals it. Defaults to self.cmp(other) != Ordering.Greater.

function

lt

(self, other: Self) -> bool throws never

Whether self orders strictly before other. Defaults to self.cmp(other) == Ordering.Less.

function

max

(self, other: Self) -> Self throws never

Ties return self, so max is stable when two values compare Equal without being interchangeable.

function

min

(self, other: Self) -> Self throws never

Ties return self, matching max.

Source:<builtin>/baml/ns_ops/comparison.bamlbytes 12052–12500

baml.ops.Equals for bool

Instance methods

function

eq

(self, other: bool) -> bool throws never
function

neq

(self, other: Self) -> bool throws never

Whether self and other differ. Defaults to !self.eq(other).

Override this only to compute the answer more directly; an override that disagrees with !eq leaves the pair inconsistent. Equals for null overrides it with a constant false, which is consistent because null has exactly one value.

Source:<builtin>/baml/ns_ops/comparison.bamlbytes 11934–12050