Lua learning-1

Source: Internet
Author: User

I plan to learn quick cocos2dx recently, so I plan to learn about the Lua language first. Lua is a small script language that is lightweight and easy to expand.

The basic data types of Lua scripts include nil, Boolean, number, String, userdata, function, thread, and table. Table is a special data structure in Lua, some are like struct in C ++ and some are like class.

The NIL type indicates a null value, indicating nothing.

Lua variables are classified into global variables and local variables. Local variables are defined as local variables. If local variables are not defined, they represent global variables.

Lua Function Definition: defines a function with the keyword "function" and ends with the keyword "end". For example, function add (a, B) Local sum = a + BReturn sum end.

Lua table definition: A ={}, B = {2, 4, 5}, c = {A = 32}, traverse the Lua table, for K, V in pairs (c) do print (K, v) End

 

Lua learning-1

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.