Programming in Lua

Source: Internet
Author: User

I. Function

1. as an expression or parameter, all results are obtained only when the call is the last expression or parameter. The rest can only obtain the first result (when the function does not return a value, the first result is nil)

1) expression:... = F1 (), F2 (), F3 ()

2) parameters: F (F1 (), F2 (), F3 ())

F (F1 () .. F2 () .. F3 ())

Obtain the first result of F1 () and F2 (), all the results of F3 ()

2. the constructor collects all parameters of the expression,

The {F1 (), F2 (), F3 ()} constructor contains the first result of F1, F2, and all the results of F3.

3. When enclosed in parentheses, only the first result is always obtained.

F (F3 () returns only the first result of F3.

4. Unpack: the input is an array, and the output is all elements in the array.

Unpack {10, 20, 30}

5. variable parameters

The number of variable parameters of select ('#',...)

Select (I,...) Variable Parameter I

6. function: First value, lexical Scope

7. High-Order Function: contain function argument;

 

Programming in Lua

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.