- TABLE 类型实现了一个关联数组, 数组的索引可以用任意类型的值(除了nil),而不限于数字。 这使得TABLE的用法十分的广泛,它可以用来描述原始的数组、符号表、集合、 记录、图、树、等等。
- LUA 语言本身采用一种语法糖,支持以 a.name 的形式表示 a["name"]。
- 跟索引一样, table 每个域中的值也可以是任何类型(除 nil外)。
- 因为函数本身也是值,所以 table 的域中也可以放函数。
TABLE的构造语法
实例
Table还提供了一些方法操作数组,非正整数的索引名称不在操作范围里边,更多的方法了解查看LUA的API 文档,这里只介绍几个常用的。
concat 合并方法
insert 插入方法
remove 移出方法
特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.