Skip to content

Instantly share code, notes, and snippets.

@wakproductions
Last active April 26, 2017 01:58
Show Gist options
  • Save wakproductions/c80b928366990849fe3ef787d21ca8a0 to your computer and use it in GitHub Desktop.
Save wakproductions/c80b928366990849fe3ef787d21ca8a0 to your computer and use it in GitHub Desktop.
Learning Elixir

Things that jumped out at me while learning Elixir

Cons operator

In addition to the aforementioned functions, you can use pattern matching and the cons operator | to split a list into head and tail; we’ll learn more about this pattern in later lessons:

iex> [h|t] = [3.14, :pie, "Apple"]
[3.14, :pie, "Apple"]
iex> h
3.14
iex> t
[:pie, "Apple"]

Iterating

Comprehension:

for x <- 0..10, do: IO.puts x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment