Lua元表的使用
来源:互联网 发布:怎么弄网络平台卖东西 编辑:程序博客网 时间:2024/04/28 18:43
Window = {}Window.prototype = {x = 0, y = 0, width = 100, height = 200,}Window.mt = {}function Window.new( o )setmetatable( o, Window.mt )return oendWindow.mt.__index = function ( table, key )return Window.prototype[key]endw = Window.new{x = 10, y = 20}print(w.width)function setDefault( t, d )local mt = {__index = function() return d end}setmetatable( t, mt )endtab = {x = 10, y = 20 }print( tab.x, tab.y, tab.z )setDefault( tab, 0 )print( tab.x, tab.y, tab.z )
0 0
- Lua元表的使用
- Lua元表的定义和使用
- lua的元表
- lua的元表
- lua的元表
- Lua元方法的使用
- lua元表的理解
- LUA元表的正确理解
- Lua中__newindex元方法的使用
- lua 的元表和元表的__index字段
- LUA元表、元操作
- Lua 元表 元方法
- lua 元表 __index 继承的实现
- Lua 的元表怎么理解
- Lua元表的基础示例。
- lua 元表
- lua元表学习
- lua元表
- Android开发之连接MySQL数据库(一)
- 单链表的实现
- [5]白盒测试方法2—图覆盖准则
- Android SQLite数据库
- vim配置及插件安装管理(超级详细)
- Lua元表的使用
- HDOJ杭电1004 Let the Balloon Rise
- 黑客讲述渗透Hacking Team全过程(详细解说)
- python学习——编写API
- React Native之PanResponder讲解与应用
- 关于Android四大组件最权威最深刻最准确的解读
- 简化函数调用(二)
- 1034: 7, 还是7
- Android数据的保存和读取