使用此代码:
for n in pairs(_G) do print(n) end
Run Code Online (Sandbox Code Playgroud)
我打印当前环境中定义的所有全局变量的名称.
有没有办法打印所有Lua的关键字(and,break,do,else,elseif,end,false,for,function,if,in,local,nil,not,or,repeat,return,then,true,until,while)?
不,因为保留关键字不对应于内存中的任何对象 - 它们仅存在于解析器中.有关完整列表,请参阅每个版本的手册,典型地在"词汇约定"下.例如,对于Lua 5.1,它位于http://www.lua.org/manual/5.1/manual.html#2.1
| 归档时间: |
|
| 查看次数: |
1854 次 |
| 最近记录: |