Recently I tested Erlang's pitfalls...
In case of any exceptions ....
At first glance, we can see this syntax...
The first sentence in my mind must be "I wiped it. What is this TM !!!!! "
No variable !!!
No struct !!!
No loop !!!
Well, at least I think so.
I have been searching for a long time. I don't even know how to write an IF ..
This record some basic knowledge ..
-Module (module_name) % defines that the module should be in the same brackets as the file name.
-Export ([fun1/1 fun2/2]) % here is the name of the function/parameter used for exporting two functions.
A simple function is defined as follows:
Function (argv)->
Case argv
0-> "hello ";
1-> "Frodo ";
2-> "Vincent ";
_-> "Know command"
End.
Which means
Judgment Parameter
If it is 0, the hello character is returned !!
By the way, there is no return for. Erlang.
The last line of the function execution is the return value.
If it is 1, The Frodo character is returned.
_ Is the meaning of default.
Note that each case is followed by a semicolon and the end must end !!!!
Remember that the last case is not followed; semicolon
And the end is OK.
Digest it first
_ Is the meaning of default.