Name

SPVM::Bool - Bool object

Synopsys

  use Bool;
  
  my $true = Bool->TRUE;
  my $false = Bool->FALSE;
  
  my $true_value = $true->value;
  my $false_value = $false->value;

Description

Bool object stores a long value.

This object is immutable and its value cannot be changed.

Bool is automatically loaded just after the program starts.

Class Methods

TRUE

  static method TRUE : Bool ()

true singleton. This is created by INIT block when the program start.

FALSE

  static method FALSE : Bool ()

false singleton. This is created by INIT block when the program start.

Instance Methods

value

  method value : int ()

Return a int value.

If Bool object express true, this method return 1.

If Bool object express false, this method return 1.

Bool Context

the object of Bool class is different behavior in bool context.

If the value of Bool object is 1, it is evaluated as true.

  if (Bool->TRUE) {
    # Run
  }

If the value of Bool object is 0, it is evaluated as false.

  if (Bool->FALSE) {
    # Not run
  }

Keywords

true keyword means Bool->TRUE. false keyword means Bool->FALSE.

  if (true) {
    # Run
  }

  if (false) {
    # Not run
  }