#elixir
We can check if a function is of any given arity by using is_function/2
:
# check if add is a function that expects exactly 2 arguments iex > is_function ( add , 2 ) true # check if add is a function that expects exactly 1 argument iex > is_function ( add , 1 ) false
If you want to change selection, open document below and click on "Move attachment"
Basic types - The Elixir programming language, just remember that Elixir makes a clear distinction between anonymous functions and named functions. Anonymous functions in Elixir are also identified by the number of arguments they receive. <span>We can check if a function is of any given arity by using is_function/2: # check if add is a function that expects exactly 2 arguments iex> is_function(add, 2) true # check if add is a function that expects exactly 1 argument iex> is_function(add, 1) false Finally, anonymous functions can also access variables that are in scope when the function is defined. This is typically refered to as closures, as they close over their scope. Let’s de Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details