ESC
Type to search...
S
Soli Docs

Booleans

True and false values with methods for type conversion and introspection.

Creating Booleans

let active = true
let disabled = false
let typed: Bool = true

# From comparisons
let result = 5 > 3       # true
let equal = "a" == "b"   # false

Conversion Methods

.to_s / .to_string

Convert to string representation.

true.to_s    # "true"
false.to_string  # "false"
.to_i / .to_int

Convert to integer (true = 1, false = 0).

true.to_i    # 1
false.to_int # 0

Introspection Methods

.class

Returns the type name as a string.

true.class   # "bool"
false.class  # "bool"
.inspect

Returns a developer-friendly string representation.

true.inspect   # "true"
false.inspect  # "false"
.is_a?(type_name)

Check if the value is of the given type. Supports "bool" and "object".

true.is_a?("bool")     # true
true.is_a?("object")   # true
true.is_a?("int")      # false
.nil?

Returns false (booleans are never nil).

true.nil?    # false
false.nil?   # false
.blank? / .present?

false is considered blank; true is present. This follows Ruby on Rails conventions.

true.blank?    # false
true.present?  # true
false.blank?   # true
false.present? # false