Elixir

Quick recap

Getting started

 

Interactive mode
iex 

Scripts - .exs

 
iex> 40 + 2
42
iex> "hello" <> " world"
"hello world"
$ elixir simple.exs
Hello world from Elixir
iex> 1          # integer
iex> 0x1F       # integer
iex> 1.0        # float
iex> true       # boolean
iex> :atom      # atom
iex> "elixir"   # string
iex> [1, 2, 3]  # list
iex> {1, 2, 3}  # tuple

Atoms

Atoms are constants where their name is their own value. Some other languages call these symbols:

iex> :hello
:hello
iex> :hello == :world
false

Atoms

 
iex> true == :true
true
iex> is_atom(false)
true
iex> is_boolean(:false)
true

Strings

 

Lists

 

Tuples

 

List or Tuples?

 

Pattern Matching

 

Pin operator

 

Processes

 
iex> send self(), {:hello, "world"}
{:hello, "world"}
iex> receive do
...>   {:hello, msg} -> msg
...>   {:world, msg} -> "won't match"
...> end
"world"

Processes

 
iex> receive do
...>   {:hello, msg}  -> msg
...> after
...>   1_000 -> "nothing after 1s"
...> end
"nothing after 1s"

Enumerables

The Enum module provides a huge range of functions to transform, sort, group, filter and retrieve items from enumerables. It is one of the modules developers use frequently in their Elixir code.

Eager vs Lazy

 

Pipe operator

 

Tooling

 

MIX

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nec metus justo. Aliquam erat volutpat.

$ mix new kv --module KV
* creating README.md
* creating .gitignore
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/kv.ex
* creating test
* creating test/test_helper.exs
* creating test/kv_test.exs

Books

 

Tips

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi nec metus justo. Aliquam erat volutpat.

That's all!

deck

By Gustavo Andrade