-
-
Save cored/f59855cfd1b0f1b2f2d770302e27b85a to your computer and use it in GitHub Desktop.
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 Examples do | |
# basic defintion | |
def do_stuff( params ) do | |
"result" | |
end | |
#shorthand syntax | |
def shorthand(), do: "result" | |
# defp is for private functions | |
defp private_method, do: "private" | |
# params can pattern match | |
def match_this(%{:key => value}), do: value | |
# the first matching function is called (order matters) | |
def test(test), do: "matches any param" | |
def test([]), do: "never matched" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment