Conftg={ hello="Hello Lua", world="World"} Config.words="Hello" Config.num=180 Config["name"]="ZhangSan" print(Config["words"]) print(Config. name) print(Config, hello) for key, var inpairs(Config) do print(key, var) end
数组{}
1 2 3 4 5 6 7 8 9 10
arr = {1,2,3,'hello'} for k,v inpairs(arr) do print(k,v) end
functionPeople() local self = {} functioninit( name ) self.name = name end
functionsayHello() print("Hello "..self.name) end init() return self end
-- 继承 functionMan(name) local self= People(name) -- local function init() -- end self.sayHello=function() print("hello"..self.name) end return self end