4.5. kink/BOOL

Companion mod for bool vals.

4.5.1. type bool

Bool vals are true or false,

See `if` preloaded fun for 1-way or 2-way branch.

For multi-way branch, use `branch` preloaded fun.

See `op_lognot`, `op_logor`, `op_logand` preloaded funs for logical operations. They are translated from !, ||, and && operators. Example:

# whether S has a whitespace character on the head or the tail
:strippable? <- {(:S)
  ! S.empty? && (S.get(0) == 0x20 || S.get(S.size - 1) == 0x20)
}

stdout.print_line(strippable?('foo').repr)  # => false
stdout.print_line(strippable?(' foo').repr) # => true
stdout.print_line(strippable?('foo ').repr) # => true
stdout.print_line(strippable?('').repr)     # => false

4.5.1.1. Bool.op_eq(Arg_bl)

Bool.op_eq returns whether two bool vals are equal.

Arg_bl must be a bool.

If both Bool and Arg_bl are true, or both Bool and Arg_bl are false, Bool.op_eq returns true.

If Bool is true and Arg_bl is false, or Bool is false and Arg_bl is true, Bool.op_eq returns false.

Note that an expression “X == Y” is translated to “(X).op_eq(Y)”. See Semantics section of the manual.

4.5.1.2. Bool.repr

Bool.repr returns "true" for true, "false" for false.

4.5.2. BOOL.is?(Val)

BOOL.is? returns whether the Val is a bool val.

Example:

:BOOL.require_from('kink/')
stdout.print_line(BOOL.is?(true).repr)   # => true
stdout.print_line(BOOL.is?(false).repr)  # => true
stdout.print_line(BOOL.is?(42).repr)     # => false