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 - it's based on our experience of managing over 50-people strong company. The tool we're missing as a small company and not an enterprise.

humadroid.io is an employee and performance management software. It's an unique tool allowing everyone to be in the loop - by having up to date info about co-workers, time-off, benefits, assets, helping with one-on-ones, being a go-to place for company-wide announcements.

Check out 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!