"Sputnik" help  
Sputnik Help
Boolean(<value>)

Description

Converts the specified value to a boolean. If the value is already a boolean, it returns it as is. If the value cannot be feasibly converted to a boolean within the scope of this function, it returns false.

Parameters

<value> The value to be converted to a boolean.

Return Value

Success: Returns the boolean representation of the specified value (true or false).
Failure: Returns false if the value cannot be converted to a boolean within the scope of this function.

Remarks

Boolean is an alias for the Bool function. It is used interchangeably to explicitly convert a value to a boolean type. If the provided value is already a boolean, it is returned without modification. If the conversion is not feasible within the scope of this function, it returns false.

Related

Casting, IsVarBool, Bool

Example

Example of usage:

my $result = Bool(42);
say $result;
// PRINTS
// true

my $flag = Bool("true");
say $flag;
// PRINTS
// true

my $status = Bool("non-boolean");
say $status;
// PRINTS
// false

Casting:

my $result = (Bool)42;
say $result;
// PRINTS
// true

Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org