Erlang initial experience

Source: Internet
Author: User


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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.