Guard clauses allow Elixir to determine which function to invokebased not only on which arguments are passed, but also based ontype or some tests involving their values. Guard clauses are definedusing the when
keyword.

Elixir Guards Enjoy this cheat sheet at its fullest within Dash, the macOS documentation browser. Guard clauses allow Elixir to determine which function to invoke based not only on which arguments are passed, but also based on type or some tests involving their values. Guard clauses are defined using the when keyword. Learn Elixir in Y minutes; 0 Comments for this cheatsheet. Devhints.io / Over 352 curated cheatsheets, by developers for developers. Devhints home Other Elixir cheatsheets. Phoenix: Plug.Conn cheatsheet Erlang ETS cheatsheet Phoenix: Ecto migrations cheatsheet Phoenix: Routing cheatsheet.
Examples:
Additionally, users may define their own guards. Example: the Bitwise
module defines bnot
, ~~~
, band
, &&&
, bor
, |||
, bxor
, ^^^
,bsl
<<<
, bsr
>>>
.
Elixir Cheat Sheet
Operators
, | |
Unary operators | |
Short-circuiting operators | |
| |
Test membership in a list or range with Example: |
Functions
See main Elixir documentation for more information.
| |
See main Elixir documentation for more information.
|
Notes
Elixir Cheat Sheet Pdf
- Based on 'Expressions in guard clauses' from Elixir-Lang Getting Started Guide
