Booleans
There is no distinct boolean type in Erlang; instead, the atoms
true and false are given a special interpretation
and are used to represent boolean literals.
Sometimes we write functions that return one of two possible atomic values. When this happens, it’s good practice to make sure they return a boolean. It’s also a good idea to name your functions to make it clear that they return a boolean.
For example, suppose we write a program that represents the state
of some file. We might find ourselves writing a function
file_state(File) that returns open or
closed. When we write this function, we could think about renaming the function and letting it return a boolean. With a little thought we could rewrite our program to use a function called ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access