Boolean (bool)

A boolean object which is either true or false

Returned by

Boolean objects are returned by the following functions and methods:

Boolean methods

bool.to_int()

Returns 1 if true and 0 if false

Signature

int to_int()


bool.to_string()

Returns the string 'true' if the boolean is true or 'false' otherwise. You can also pass it two strings as positional arguments to specify what to return for true/false. For instance, bool.to_string('yes', 'no') will return yes if the boolean is true and no if it is false.

Signature

# Returns the string `'true'` if the boolean is true or `'false'` otherwise
str to_string(
  str [true_str],    # The string to return when the boolean is `true`
  str [false_str],   # The string to return when the boolean is `false`
)

Arguments

The method bool.to_string() accepts the following positional arguments:

Name Type Description Tags
true_str str

The string to return when the boolean is true

[optional]

default = 'true'

false_str str

The string to return when the boolean is false

[optional]

default = 'false'


The results of the search are