这是一个创建于 4678 天前的主题,其中的信息可能已经有所发展或是发生改变。
Lua中一个奇怪的设计:
原始读索引是rawget(t, i),原始写索引是rawset(t, k, v)。
元表的读索引却是__index,写索引是__newindex,这是什么命名,为什么不保持一致,就叫__getindex和__setindex?
1 条回复 1970-01-01 08:00:00 +08:00  | | 1 middleware 2013 年 5 月 27 日 Lua 5.2 document: Note that the metamethod (__index) is tried only when key is not present in table. |