Erlang / x export syntax understanding

-export([consult/1, dump/2, first/1, for/3, is_prefix/2). 

MEGA-Excited about erlang. I am reading the documentation and confused by the syntax above. What is the value of / 1, / 2, / 3 in the list above?

thanks Dmitry

+7
source share
2 answers

/ 1, / 2, / 3, etc. called "Arity" , Arity means the number of arguments accepted by this function.

In Erlang, two functions with the same name but with different clarity are two different functions, and as such are exported explicitly.

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 only had

 -export([do_something/0]). 

Then only do_something with zero arguments will be exported (that is, accessible from other modules in the system).

+12
source

This is the signature of the function.

consult/1 means that a function called consult takes an argument. dump/2 means that the dump function takes two arguments.

Refer to the documentation for more information.

+1
source

All Articles