Bool
The convention is to name the module alias after the file name it is defined in:
import Bool "mo:base/Bool";
Comparison
Function equal
Function notEqual
Function compare
Conversion
Logical operations
Function lognot
Function logand
Function logor
Function logxor
Bool.equal
func equal(x : Bool, y : Bool) : Bool
The function equal
takes two Bool
arguments and returns a Bool
value. It is equivalent to the ==
relational operator.
import Bool "mo:base/Bool";
let a = true;
let b = false;
Bool.equal(a, b);
Bool.notEqual
func notEqual(x : Bool, y : Bool) : Bool
The function notEqual
takes two Bool
arguments and returns a Bool
value. It is equivalent to the !=
relational operator.
import Bool "mo:base/Bool";
let a = true;
let b = false;
Bool.notEqual(a, b);
Bool.compare
func compare(x : Bool, y : Bool) : Order.Order
The function compare
takes two Bool
arguments and returns an Order variant value.
import Bool "mo:base/Bool";
let a = true;
let b = false;
Bool.compare(a, b);
Bool.toText
func toText(x : Bool) : Text
The function toText
takes one Bool
argument and returns a Text
value.
import Bool "mo:base/Bool";
let isPrincipal = true;
Bool.toText(isPrincipal);
Bool.lognot
func lognot(x : Bool) : Bool
The function lognot
takes one Bool
argument and returns a Bool
value. It stands for logical not. It is equivalent to the not
expression.
import Bool "mo:base/Bool";
let positive = true;
Bool.lognot(positive);
Bool.logand
func logand(x : Bool, y : Bool) : Bool
The function logand
takes two Bool
arguments and returns a Bool
value. It stands for logical and. It is equivalent to the and
expression.
import Bool "mo:base/Bool";
let a = true;
let b = false;
Bool.logand(a, b);
Bool.logor
func logor(x : Bool, y : Bool) : Bool
The function logor
takes two Bool
arguments and returns a Bool
value. It stands for logical or. It is equivalent to the or
expression.
import Bool "mo:base/Bool";
let a = true;
let b = false;
Bool.logor(a, b);
Bool.logxor
func logxor(x : Bool, y : Bool) : Bool
The function logxor
takes two Bool
arguments and returns a Bool
value. It stands for exclusive or.
import Bool "mo:base/Bool";
let a = true;
let b = true;
Bool.logxor(a, b);