Elixir Cheat Sheet



Sheet

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 phoenix cheat sheet

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 Bitwisemodule defines bnot, ~~~, band, &&&, bor, |||, bxor, ^^^,bsl<<<, bsr>>>.

Elixir Cheat Sheet

Operators

, !=, , !, <, >, <=, >=

+, -, *, /

Unary operators +, and - are also allowed.

or, and, not

Short-circuiting operators &&, ||, and ! are not allowed.

<>, ++ as long as left side is a literal.

Test membership in a list or range with in.

Example:

Functions

See main Elixir documentation for more information.

is_atom/1,is_binary/1,is_bitstring/1,is_boolean/1,is_float/1,is_function/1,is_function/2,is_integer/1,is_list/1,is_map/1,is_number/1,is_pid/1,is_port/1,is_record/1,is_record/2,is_reference/1,is_tuple/1

See main Elixir documentation for more information.

abs(number),binary_part(binary, start, length),bit_size(bitstring),byte_size(bitstring),div(number, number),elem(tuple, n),hd(list),length(list),map_size(map),node(), node(pid | ref | port),rem(integer, integer),round(number),self(),tl(list),trunc(number),tuple_size(tuple)

Notes

Elixir Cheat Sheet Pdf

  • Based on 'Expressions in guard clauses' from Elixir-Lang Getting Started Guide