Last active
September 27, 2018 13:04
-
-
Save toranb/71a3594d279fbbb8bacd3a9068bfdb01 to your computer and use it in GitHub Desktop.
showing how pinned values and pattern matching work in elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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