Last active
January 19, 2019 23:16
-
-
Save Tombarr/6b3b2a0bb29c58d1b5289d39098e4507 to your computer and use it in GitHub Desktop.
Functions and lambdas in Elixir
This file contains hidden or 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
def add_ten(x) do | |
x + 10 | |
end | |
add_five = fn x -> x + 5 end | |
add_two = &(&1 + 2) | |
add_ten(10) # 20 | |
add_five.(10) # 15 | |
add_two.(10) # 12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment