Detailed data types in Lua _lua

Source: Internet
Author: User
Tags lua

Lua is a dynamic type language, so a variable has no type, and only the value has a type. Values can be stored in a variable, passed as a parameter, and returned as a result.

Although we do not have variable data types in Lua, we have types of values. The list used for numeric data types is given below.


function Type

In Lua there is a type called function that allows us to know the type of the variable. Here are some examples of the following code.

Copy Code code as follows:
Print (Type ("What is my Type")--> string
t=10
Print (Type (5.8*t))--> number
Print (Type (true))--> Boolean
Print (type (print))--> function
Print (type)--> function
Print (type (nil))--> Nil
Print (Type (ABC))--> string

When the above program is established and executed, it will produce results under Linux:

Copy Code code as follows:
String
Number
function
function
Boolean
Nil
String

By default, all variables will point to nil until they are assigned a value or initialized. In Lua, 0 and empty strings are considered true, as are conditional checks. Therefore, you must be careful when using Boolean operations. We'll learn more and use these types in the following sections.

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.