Elixir Cheat Sheet
Elixir syntax, pattern matching, pipe operators, and OTP concurrency primitives for building fault-tolerant BEAM applications.
2 PagesAdvancedMar 30, 2026
Basic Syntax
Bindings, control flow, and printing.
elixir
age = 30name = "Ada"pi = 3.14159if age >= 18 do IO.puts("#{name} is an adult")endfor i <- 0..4 do IO.puts("Count: #{i}")end
Pattern Matching & Pipe Operator
Destructuring and composing transformations.
elixir
{status, message} = {:ok, "loaded"} # destructuring match[first | rest] = [1, 2, 3, 4] # head/tail matchIO.inspect(first) # 1IO.inspect(rest) # [2, 3, 4]nums = [5, 3, 1, 4, 2]result = nums |> Enum.filter(&(&1 > 2)) |> Enum.map(&(&1 * 2)) |> Enum.sum() # pipe: nums |> filter |> map |> sum
Processes & OTP
GenServer and lightweight process concurrency.
elixir
defmodule Counter do use GenServer def start_link(initial), do: GenServer.start_link(__MODULE__, initial) def init(state), do: {:ok, state} def handle_call(:get, _from, state), do: {:reply, state, state} def handle_call(:increment, _from, state), do: {:reply, state + 1, state + 1}end{:ok, pid} = Counter.start_link(0)GenServer.call(pid, :increment)GenServer.call(pid, :get) # 1
Core Keywords & Operators
Common Elixir language constructs.
- |>- pipe operator, passes left result as first arg to right function
- def / defp- public and private module function definitions
- case / cond- multi-branch pattern matching / condition dispatch
- %{}- map literal, e.g. %{name: "Ada"}
- GenServer- OTP behaviour for stateful server processes
- spawn / send / receive- lightweight process creation and message passing
- Enum / Stream- eager and lazy collection-processing modules
Pro Tip
Let it crash: rely on OTP supervisors to restart failing processes instead of wrapping every operation in defensive try/rescue — Elixir's fault tolerance is designed around supervision trees.
Was this cheat sheet helpful?
Explore Topics
#Elixir#ElixirCheatSheet#Programming#Advanced#BasicSyntax#Pattern#Matching#Pipe#Concurrency#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance