-export([consult/1,
dump/2,
first/1,
for/3,
is_prefix/2).
I'm reading documentation and confused with syntax above. What's the meaning of /1
, /2
, /3
in the list above?
/1, /2, /3
etc are referred to as the "Arity" of the function, Arity meaning the number of arguments accepted by that function.
In Erlang, two functions of with the same name but with different arity are two different functions, and as such are each exported explicitly. To quote the Erlang documentation is says:
A function is uniquely defined by the module name, function name, and arity.
For example, if you have two functions:
do_something() -> does_something().
do_something(SomeArg) -> some_something_else(SomeArg).
And at the top of your module, you had only
-export([do_something/0]).
Then only the do_something with zero arguments would be exported (that is, accessible from other modules in the system).
It is the function signature.
consult/1
means the function named consult
accepts an argument. dump/2
means the function dump
accepts two arguments.
Consult the documentation for more info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With