December 2019
Intermediate to advanced
248 pages
5h 34m
English
Elixir supports a short list of primitive types, including booleans, floats, integers, atoms, and references. We don’t have much guidance for primitive types since for the most part they behave much like they do in other languages. We do have a couple of thoughts, though.
Elixir numbers are integers and floats. Remember that floats are estimates.[4] Consider this example:
| | iex(1)> 0.1 + 0.2 |
| | 0.30000000000000004 |
Therefore, unless you’re in a position to profit illegally, prefer integers or decimals over floats when you can. Here are a few places that strategy might make, er, sense:
Read now
Unlock full access