Bool is the class for the boolean values true and false.

Methods

clone()

Get a copy of the boolean.

IO.println(true.clone()) #> true

hash

Return a hash for the boolean value: 1 for true, 2 for false.

IO.println(true.hash)  #> 1
IO.println(false.hash) #> 2

to_i

Transform the boolean value into an Int: 1 for true, 0 for false.

IO.println(true.to_i)  #> 1
IO.println(false.to_i) #> 0

to_s

Transform the boolean value into a String: "true" for true, "false" for false.

IO.println(true.to_s)  #> true
IO.println(false.to_s) #> false

Operators

! operator

Return the negation of the value.

IO.println(!true)  #> false
IO.println(!false) #> true