John Bohn

My thoughts on software, tech, business, and more

Elixir Data Types

I’ve been playing with Elixir lately and wanted to persist a few things that I thought were interesting about some of it’s core data types. It’s very basic, but if you’re just getting started with Elixir like I am, you might find these notes interesting.

Elixir has a few of the basic types you’d expect to see in any other language. For example, Elixir has integers, floats and strings. Besides those types, there are atoms (aka. symbols), lists and tuples.

Atoms look just like symbols in Ruby. They are constants whose name is also it’s value.

1
2
3
4
5
6
iex> :foo
:foo
iex> :foo == :bar
false
iex> is_atom(:foo)
true

Another interesting note is that booleans are just atoms.

1
2
3
4
iex> is_atom(true)
true
iex> false == :false
true

Lists in Elixir are linked lists. A linked list is data structure in which each node contains a reference to the next node.

Linked
list

Comments