Name
SPVM::Bool - A Boolean value as An Object
Description
The Bool class in SPVM represents a boolean value as an object.
Usage
use Bool;
my $true = Bool->TRUE;
my $false = Bool->FALSE;
my $true_value = $true->value;
my $false_value = $false->value;
Details
This class is immutable.
This class is automatically loaded.
The Bool object is different behavior in bool context.
If the "value" field is 1, it is evaluated as true.
if (Bool->TRUE) {
# Run
}
If the "value" field is 0, it is evaluated as false.
if (Bool->FALSE) {
# Not run
}
The true
keyword is the same as Bool->TRUE
.
if (true) {
# Run
}
The false
keyword is the same as Bool->FALSE
.
if (false) {
# Not run
}
Fields
value
has value : ro int;
The value.
Class Methods
TRUE
static method TRUE : Bool ();
Returns the true singleton object.
FALSE
static method FALSE : Bool ();
Returns the false singleton object.
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License