码迷,mamicode.com
首页 > 其他好文 > 详细

lua学习 4

时间:2017-02-25 23:00:34      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:返回   tar   导出   profile   路径   pos   load   class   bashrc   

table:	
tableconstructor ::= `{′ [fieldlist] `}′ fieldlist ::= field {fieldsep field} [fieldsep] field ::= `[′ exp `]′ `=′ exp | Name `=′ exp | exp fieldsep ::= `,′ | `;

每个形如 [exp1] = exp2 的域向 table 中增加新的一项, 其键值为 exp1 而值为 exp2。 形如 name = exp 的域等价于 ["name"] = exp。 最后,形如 exp 的域等价于 [i] = exp , 这里的 i 是一个从 1 开始不断增长的数字。 这这个格式中的其它域不会破坏其记数。

table.concat (table [, sep [, start [, end]]]):

table.concat (table [, sep [, start [, end]]]):

table.remove (table [, pos])

table.sort (table [, comp])

Lua 的模块是由变量、函数等已知元素组成的 table,因此创建一个模块很简单,就是创建一个 table,然后把需要导出的常量、函数放入其中,最后返回这个 table 就行。

加载模块:require("<模块名>")

require 用于搜索 Lua 文件的路径是存放在全局变量 package.path 中。如果没有 LUA_PATH 这个环境变量,也可以自定义设置,在当前用户根目录下打开 .profile 文件(没有则创建,打开 .bashrc 文件也可以)

Lua在一个叫loadlib的函数内提供了所有的c动态库连接的功能

lua学习 4

标签:返回   tar   导出   profile   路径   pos   load   class   bashrc   

原文地址:http://www.cnblogs.com/arwen-spy/p/6443101.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!