Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Latest commit

 

History

History
29 lines (21 loc) · 681 Bytes

File metadata and controls

29 lines (21 loc) · 681 Bytes

Booleans

Elixir represents true and false values with the boolean type. There are only two values: true and false. These values can be bound to a variable:

true_variable = true
false_variable = false

We can evaluate strict boolean expressions using the and/2, or/2, and not/1 operator functions.

true_variable = true and true
false_variable = true and false

true_variable = false or true
false_variable = false or false

true_variable = not false
false_variable = not true

When writing a function that returns a boolean value, it is idiomatic to end the function name with a ?.

def either_true?(a, b) do
  a or b
end