摘要:
isok = false;--逻辑运算符--规定nil为false--print( ms and isok)--print(4 and 5)--print (false and 13)--print(false and 13)--a or b a为true 返回a 否则返回b--print (4 a 阅读全文
摘要:
--单行注释--[[多行注释]]--变量声明的时候 不需要声明类型str = "Hello World"--多个变量name,age ="LanOu",4,5,10print(str)print(name,age,ad) 阅读全文
摘要:
--冒泡排序nums = {3,11,2,123,1}len = #numsfor i = 1,len-1 do for j = 1,len-i do if nums[j]>nums[j+1] then temp= nums[j+1] nums[j+1]= nums[j] nums[j]= temp 阅读全文
摘要:
--男人类man = {name = "man",age=123}--继承空间man.__index=man--儿童类child= {}--继承setmetatable(child,man)print(child.age)yong= {}setmetatable(yong,man)child.age 阅读全文
摘要:
--使用table封装面向对象beauty={name = " "}--封装对象方法function beauty.init(self, name)print("十八年前的一天王小丫出生")self.name= nameend--一般使用下面这种形式function beauty:init( nam 阅读全文
摘要:
function SayHey(mag) for i = 1 , 3 doprint(mag)coroutine.yield()end end --创建携程(协同) coFunc= coroutine.create(SayHey)--查看携程状态print(coroutine.status(coFu 阅读全文
摘要:
--require("6-Coroutine")--仅加载一次,并不执行--dofile("6-Coroutine.lua") --加载并执行--SayHey("kkkk")x=10 --默认是全局变量 show= function()local x = 1for i = 1 ,5 dox = x+ 阅读全文