Lua learning notes --- selection, cyclic statements, lua learning notes --- statements

Source: Internet
Author: User

Lua learning notes --- selection, cyclic statements, lua learning notes --- statements


Note: parentheses can be removed.

2> if condition then branch 1 else branch 2 end

3> if condition 1 then branch 1 elseif condition 2 then branch 2 end


2. Loop statements

1> while LOOP


Note: No auto-subtraction, auto-Addition
2> for Loop
Form: for initial value, final value, step do branch end
The step is optional. If there is no step, the default value is 1;

Note: I starts from 0 and Adds 1 each time until I = 4 and runs print five times. The three parameters (expressions) IN THE for loop are calculated once before the loop, it does not run in every loop. However, local variables in the for loop can only be seen internally.

3> repeat ...... Until statement
Form: repeat branch until Condition

4> break Out Loop

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.