Catalog / Elixir Cheat Sheet
Elixir Cheat Sheet
A comprehensive cheat sheet for Elixir, covering syntax, data types, control flow, modules, and more, with examples.
Getting Started & Basic Syntax
Basic Structure
Elixir is a functional, concurrent language built on the Erlang VM.
|
Running Elixir Code
|
Hello, World!
|
Output
|
Variables
Variables are immutable; you cannot change the value of an existing variable. |
|
Data Types
Primitive Types
|
Nil/null value. |
|
Boolean values. |
|
Integer (ASCII) value. |
|
Integer value. |
|
Float value. |
|
Charlist (list of characters). |
|
Binary data. |
|
Binary string. |
|
Atom (a constant with name). |
Collections
|
List (ordered collection). |
|
Tuple (ordered, fixed-size collection). |
|
Map (key-value pairs). |
|
Struct (extension of map, with predefined keys). |
Functions
Anonymous function (lambda). |
Type Checks
Functions to check the type of a value. |
Control Flow & Operators
Control Flow
If
|
Case
|
Cond
|
With
|
Error Handling
|
Operators
|
Not equal. |
|
Strict not equal(no type conversion). |
|
Concatenate lists. |
|
Concatenate string/binary. |
|
Regexp match. |
Modules and Functions
Modules
|
Accessing a Function:
|
Importing and Aliasing
|
Example:
can be written as
|
String Functions
|
Anonymous Functions (Lambdas)
Shorthand Syntax
|
Function Heads and Pattern Matching
|
Advanced Features
Structs
|
Protocols
|
Comprehensions
For Loops
Conditions
Into
|
Metaprogramming
|
Regular Expressions
|
Sigils
|