Skip to content

Instantly share code, notes, and snippets.

@toranb
Last active September 27, 2018 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toranb/71a3594d279fbbb8bacd3a9068bfdb01 to your computer and use it in GitHub Desktop.
Save toranb/71a3594d279fbbb8bacd3a9068bfdb01 to your computer and use it in GitHub Desktop.
showing how pinned values and pattern matching work in elixir
defmodule Robot do
def speak(name, phrase) do
fn
(^name) -> "hello! #{name}, #{phrase}"
(_) -> "sorry ... don't know this name"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment