Data Types
Elixir has a simple set of data types—the usual suspects are all here. You use these types to store your application data and pass it as arguments to functions.
Ruby differs a bit in what you can do with basic data types. Everything in Ruby (including basic data types) is an object, so you can add methods to the object class in order to extend the data type. For example, Ruby on Rails has implemented methods to make syntax like 10.days.from_now possible. This works because ActiveSupport has extended the Integer class with these methods.
The design of Ruby’s object extension is elegant, but you won’t find it in Elixir. This isn’t necessarily a bad thing though. Functions in Elixir are explicitly invoked with the module name—more on ...
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