Want to learn?

Booleans

Representation

Documentation

There are two boolean values supported by Elixir: true and false. There is, however, one more value that in the context of logical operations acts as false. This value is nil. Any value that is not nil or false will be treated as true.

You can check if given value is boolean with is_boolean/1 function:

iex> is_boolean 1
false
iex> is_boolean true
true

Logical operators

Boolean operators

The following operator requires the first argument to be either true or false.

a or b -> if the first argument is true then true, otherwise b
a and b -> if the first argument is true then b, otherwise false
not a -> if the argument is true then false, otherwise true

Relaxed boolean operators

Unlike previously introduced operators, relaxed boolean operators work with arguments of any type.

a || b -> if the first argument is true then a, otherwise b
a && b -> if the first argument is true then b, otherwise a
!a -> if the argument is true then false, otherwise true
Check our latest product - built from our experience helping growing businesses navigate complex compliance requirements without enterprise budgets.

humadroid.io is an affordable, all-in-one GRC platform designed for small and medium-sized businesses pursuing SOC 2 or ISO 27001 compliance. Our AI-powered compliance assistant understands your business context and transforms complex compliance work into actionable steps - generating tailored policy documentation in minutes instead of weeks, and helping draft your SOC 2 System Description in a fraction of the usual time. At just $250/month with no hidden fees or user limits, customers save 10-15 hours per week on compliance work.

Explore humadroid.io
Top

Contact us

* Required fields

The controller of your personal data provided via this contact form is Prograils sp. z o.o., with a registered seat at Sczanieckiej 9A/10, 60-215 PoznaƄ. Your personal data will be processed in order to respond to your inquiries and for our marketing purposes (e.g. when you ask us for our post-development, maintenance or ad hoc engagements for your app). You have the rights to: access your personal data, rectify or erase your personal data, restrict the processing of your personal data, data portability and to object to the processing of your personal data. Learn more.

Notice

We do not track you online. We use only session cookies and anonymous identifiers for the purposes specified in the cookie policy. No third-party trackers.

I understand
Elo Mordo!Elo Mordo!