Skip to content

Instantly share code, notes, and snippets.

@ScottRadcliff
Last active April 20, 2019 15:54
Show Gist options
  • Save ScottRadcliff/1ef12047cc183b311432cfe9614ca587 to your computer and use it in GitHub Desktop.
Save ScottRadcliff/1ef12047cc183b311432cfe9614ca587 to your computer and use it in GitHub Desktop.
Values in signature
defmodule Sample.Signature do
def match(1), do: IO.puts "Matched 1"
def match(2), do: IO.puts "Matched 2"
def match(number), do: IO.puts "Matched #{number} dynamically"
end
# iex "signature.exs"
# Sample.Signature.match(1)
# Matched 1
# :ok
#
# Sample.Signature.match(2)
# Matched 2
# :ok
#
# Sample.Signature.match(22)
# Matched 22 dynamically
# :ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment