Types and values of LUA learning

Source: Internet
Author: User

Lua is a dynamic language that has no type-defined syntax in the language.

There are 8 basic types in Lua:

1.nil (empty)

2.boolean

3.number (digital)

4.string (String)

5.userdata (custom type)

6.function (function)

7.thread (thread)

8.table (table)

The function type can return the name of a type based on a value.

Print (type("HelloWorld"------------->string

Since there are no predefined types of variables,

Ten ; Print (type--------------------->numberprint;        -- ----------------------> Note This is legal. Print (type----------------------->function

Here we focus on the string type.

LUA strings are immutable values, and if modified can only create a new string:

"  One "  string.gsub(A,"One","One"); Print (a); -- ------------>one Print (b); -- ------------>two

LUA's strings, like other Lua objects, are objects managed by the automatic memory management mechanism.

You can also use a pair of matching brackets to define an alphabetic string so that you can extend multiple lines, but Lua does not interpret the escape characters.

Such as:

[[]] write (page);

LUA provides run-time numeric and string auto-conversions.

Print ("+"+1------------------>21print("  Hello"+2); -- --------------> Errors

In contrast, LUA can also convert a string into a number

Print (a); -- ---------------->1020

In Lua: Represents a string connection operator.

Types and values of LUA learning

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.