Pure Lua under MAC (ii)

Source: Internet
Author: User
Tags assert lua unpack

LUA Library

Basic functions

ASSERT (V,[,message])

When V is false, a message is returned

ASSERT (Money >0, "error-1001");

CollectGarbage ([Opt,[arg]]);//garbage collection related

Collet Stop Restart count step setpause Setstepmul

View memory is CollectGarbage ("count");

Error (Message,[,level]);

Error ("This operations is invalid");

_g global variables contain all of the global variables and functions

Getfenv ([f]) The current environment used by the current function f can be a function or a number

Getmetable (object) The current object has an associated metatable

Ipairs (t) output continuous array format

Load (Func[,chunkname]))???

LoadString (String, "Chunkname")???

Next (table, "index")

T = {"One", "Deux", "Drei", "Quarto"};

Print (Next (t,3));//Prints out key value//t[3] only prints out value

Pairs (t) Traversal object

Pcall (f,arg1,...) function protection situation Call

Rawget (table,index) equals table "index"

Rawset (Table,index,value) equals table[index] = value;

Select (Index,...) //???

Setfenv (f,table)//Setting the environment of the function

Setmetatable (table,metatable);

Tonumber (), ToString () type conversion

Type () view type//nil,number,string,boolean,table,thread,userdata

Unpack (List,[i,[j]]);//

MYT = {1,2,3,4,5,5,6,7,78,8,8,9};
Print (Unpack (myt,3,8))

System Library

Common libraries have table string math file os

Table functions

Table.concat (atable,start,end);//The value of the printed table

Table.insert (Atable,pos,value)

Table.remove (Atable,pos);

Table.sort (Atable,compare)//The second parameter is called after each comparison

OS functions

Os.clock ();//clock interval, CPU interval for executing instructions

Os.date ();//Date

Os.difftime ()//Time difference

Os.remove (filename);//removing files

Os.rename (oldname,newname);//Modify file name

Os.time ()//Time

Os.tmpname ();//Random name

Common Uses of table

As an array

As a hash table (Key,value)

. And: The difference

The colon includes itself.

Pure Lua under MAC (ii)

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.