Lua Table和面向对象
me = {}
me.speed = 999999
local this = me

me.run = function()
	print("于是就像风那样跑了过来")
	print("速度达到"..this.speed)
end

me.seeYou = function()
	print("我看到了你")
	this.run()
end

me.seeYou()

Lua如果要表达面向对象的思想,只能通过Table数据类型来实现了

可以定义方法和属性


首页 我的博客
粤ICP备17103704号