std.bool.Bool
Valueclass pub builtin Bool
The class for boolean true
and false
.
Instance methods
!=
Show source codeHide source code
fn pub !=(other: T) -> Bool {
(self == other).false?
}
fn pub !=(other: T) -> Bool
Returns true
if self
and the given object are not equal to each other.
<
Show source codeHide source code
fn pub <(other: ref T) -> Bool {
match cmp(other) {
case Less -> true
case _ -> false
}
}
fn pub <(other: ref T) -> Bool
Returns true
if self
is lower than the given argument.
<=
Show source codeHide source code
fn pub <=(other: ref T) -> Bool {
match cmp(other) {
case Less or Equal -> true
case _ -> false
}
}
fn pub <=(other: ref T) -> Bool
Returns true
if self
is lower than or equal to the given argument.
==
Show source codeHide source code
fn pub ==(other: ref Bool) -> Bool {
_INKO.int_eq(self, other)
}
fn pub ==(other: ref Bool) -> Bool
Returns true
if self
and the given object are equal to each other.
This operator is used to perform structural equality. This means two objects residing in different memory locations may be considered equal, provided their structure is equal. For example, two different arrays may be considered to have structural equality if they contain the exact same values.
>
Show source codeHide source code
fn pub >(other: ref T) -> Bool {
match cmp(other) {
case Greater -> true
case _ -> false
}
}
fn pub >(other: ref T) -> Bool
Returns true
if self
is greater than the given argument.
>=
Show source codeHide source code
fn pub >=(other: ref T) -> Bool {
match cmp(other) {
case Greater or Equal -> true
case _ -> false
}
}
fn pub >=(other: ref T) -> Bool
Returns true
if self
is equal to or greater than the given argument.
clone
Show source codeHide source code
fn pub clone -> Bool {
self
}
fn pub clone -> Bool
Creates a clone of self
.
cmp
Show source codeHide source code
fn pub cmp(other: ref Bool) -> Ordering {
to_int.cmp(other.to_int)
}
fn pub cmp(other: ref Bool) -> Ordering
Returns the ordering between self
and the given argument.
The returned value should be as follows:
a == b
:Ordering.Equal
a > b
:Ordering.Greater
a < b
:Ordering.Less
false?
Show source codeHide source code
fn pub false? -> Bool {
self == false
}
fn pub false? -> Bool
Returns true
if self
is false
.
Examples
true.false? # => false
false.false? # => true
fmt
Show source codeHide source code
fn pub fmt(formatter: mut Formatter) {
if self { formatter.write('true') } else { formatter.write('false') }
}
fn pub fmt(formatter: mut Formatter)
Formats self
in a human-readable format for debugging purposes.
hash
Show source codeHide source code
fn pub hash[H: mut + Hasher](hasher: mut H) {
hasher.write(to_int)
}
fn pub hash[H: mut + Hasher](hasher: mut H: mut)
Writes the hash for self
into the given Hasher
.
then
Show source codeHide source code
fn pub then[T](func: fn -> T) -> Option[T] {
if self { Option.Some(func.call) } else { Option.None }
}
fn pub then[T](func: fn -> T) -> Option[T]
Calls the supplied closure and wraps its return value in a Some
if self
is true
, otherwise returns a None
.
Examples
true.then fn { 10 } # => Option.Some(10)
false.then fn { 10 } # => Option.None
to_int
Show source codeHide source code
fn pub to_int -> Int {
self as Int64 as Int
}
fn pub to_int -> Int
Converts self
to a Int
to_string
Show source codeHide source code
fn pub to_string -> String {
if self { 'true' } else { 'false' }
}
fn pub to_string -> String
Converts self
to a String
.
true?
Show source codeHide source code
fn pub true? -> Bool {
self
}
fn pub true? -> Bool
Returns true
if self
is true
.
Examples
true.true? # => true
false.true? # => false
Implemented traits
Clone
impl Clone[Bool] for Bool
Compare
impl Compare[Bool] for Bool
Equal
impl Equal[ref Bool] for Bool
Format
impl Format for Bool
Hash
impl Hash for Bool
ToInt
impl ToInt for Bool
ToString
impl ToString for Bool