struct
Bool
The primitive Bool scalar value used in Mojo.
Fields
- value (
i1
): The underlying storage of the boolean value.
Implemented traits
AnyType
,
Boolable
,
CollectionElement
,
Comparable
,
ComparableCollectionElement
,
Copyable
,
EqualityComparable
,
Indexer
,
Intable
,
Movable
,
Stringable
Methods
__init__
__init__(value: i1) -> Self
Construct a Bool value given a __mlir_type.i1 value.
Args:
- value (
i1
): The initial __mlir_type.i1 value.
Returns:
The constructed Bool value.
__init__(value: scalar<bool>) -> Self
Construct a Bool value given a !pop.scalar<bool>
value.
Args:
- value (
scalar<bool>
): The initial value.
Returns:
The constructed Bool value.
__init__[boolable: Boolable](value: boolable) -> Self
Implicitly convert a Boolable value to a Bool.
Parameters:
- boolable (
Boolable
): The Boolable type.
Args:
- value (
boolable
): The boolable value.
Returns:
The constructed Bool value.
__bool__
__bool__(self: Self) -> Self
Convert to Bool.
Returns:
This value.
__neg__
__neg__(self: Self) -> Int
Defines the unary -
operation.
Returns:
0 for -False and -1 for -True.
__invert__
__invert__(self: Self) -> Self
Inverts the Bool value.
Returns:
True if the object is false and False otherwise.
__lt__
__lt__(self: Self, rhs: Self) -> Self
Compare this Bool to RHS using less-than comparison.
Args:
- rhs (
Self
): The rhs of the operation.
Returns:
True if self is False and rhs is True.
__le__
__le__(self: Self, rhs: Self) -> Self
Compare this Bool to RHS using less-than-or-equal comparison.
Args:
- rhs (
Self
): The rhs of the operation.
Returns:
True if self is False and rhs is True or False.
__eq__
__eq__(self: Self, rhs: Self) -> Self
Compare this Bool to RHS.
Performs an equality comparison between the Bool value and the argument.
This method gets invoked when a user uses the ==
infix operator.
Args:
- rhs (
Self
): The rhs value of the equality statement.
Returns:
True if the two values match and False otherwise.
__ne__
__ne__(self: Self, rhs: Self) -> Self
Compare this Bool to RHS.
Performs a non-equality comparison between the Bool value and the
argument. This method gets invoked when a user uses the !=
infix
operator.
Args:
- rhs (
Self
): The rhs value of the non-equality statement.
Returns:
False if the two values do match and True otherwise.
__gt__
__gt__(self: Self, rhs: Self) -> Self
Compare this Bool to RHS using greater-than comparison.
Args:
- rhs (
Self
): The rhs of the operation.
Returns:
True if self is True and rhs is False.
__ge__
__ge__(self: Self, rhs: Self) -> Self
Compare this Bool to RHS using greater-than-or-equal comparison.
Args:
- rhs (
Self
): The rhs of the operation.
Returns:
True if self is True and rhs is True or False.
__and__
__and__(self: Self, rhs: Self) -> Self
Returns self & rhs
.
Bitwise and's the Bool value with the argument. This method gets invoked
when a user uses the and
infix operator.
Args:
- rhs (
Self
): The right hand side of theand
statement.
Returns:
self & rhs
.
__or__
__or__(self: Self, rhs: Self) -> Self
Returns self | rhs
.
Bitwise or's the Bool value with the argument. This method gets invoked
when a user uses the or
infix operator.
Args:
- rhs (
Self
): The right hand side of theor
statement.
Returns:
self | rhs
.
__xor__
__xor__(self: Self, rhs: Self) -> Self
Returns self ^ rhs
.
Bitwise Xor's the Bool value with the argument. This method gets invoked
when a user uses the ^
infix operator.
Args:
- rhs (
Self
): The right hand side of thexor
statement.
Returns:
self ^ rhs
.
__rand__
__rand__(self: Self, lhs: Self) -> Self
Returns lhs & self
.
Args:
- lhs (
Self
): The left hand side of theand
statement.
Returns:
lhs & self
.
__ror__
__ror__(self: Self, lhs: Self) -> Self
Returns lhs | self
.
Args:
- lhs (
Self
): The left hand side of theor
statement.
Returns:
lhs | self
.
__rxor__
__rxor__(self: Self, lhs: Self) -> Self
Returns lhs ^ self
.
Args:
- lhs (
Self
): The left hand side of thexor
statement.
Returns:
lhs ^ self
.
__iand__
__iand__(inout self: Self, rhs: Self)
Computes self & rhs
and store the result in self
.
Args:
- rhs (
Self
): The right hand side of theand
statement.
__ixor__
__ixor__(inout self: Self, rhs: Self)
Computes self ^ rhs
and stores the result in self
.
Args:
- rhs (
Self
): The right hand side of thexor
statement.
__ior__
__ior__(inout self: Self, rhs: Self)
Computes self | rhs
and store the result in self
.
Args:
- rhs (
Self
): The right hand side of theor
statement.