【发布时间】:2012-11-08 09:37:29
【问题描述】:
我想重写一个函数来检查它的参数值,但调用它并正常传递原始参数。这可能吗?我正在使用 www.coronalabs.com 的 Corona SDK
我目前无法使用的代码是:
-- getting a refrence to the original function so i can replace it with my overriding function
local newcircle = display.newCircle
-- my override
display.newCircle = function(...)
-- attempt to pass the parameters to this function on to the real function
local t = {...}
newcircle(unpack(t))
end
-- calling the overridden function as if it were normal
display.newCircle( display.newGroup(), "image.png" )
【问题讨论】:
-
如果
newCircle接受两个参数,为什么要用...使事情复杂化? -
您应该将原始(有问题的)代码留在问题中。如果换成修正版,其他人很难看清问题的原意。
标签: function parameters lua arguments