__index

Window = {}
Window.prototype = {x = , y = , width = , height = }
Window.mt = {} function Window.new(o)
setmetatable(o, Window.mt)
return o
end --[[Window.mt.__index = function (table, key)
return Window.prototype[key]
end--]] Window.mt.__index = Window.prototype--当我们想不通过调用__index metamethod来访问一个表,我们可以使用rawget函数, w = Window.new{x = , y = }
print(w.width)
上一篇:Linux Shell编程三


下一篇:Objective-C的内省(Introspection)小结