lua-users home
lua-l archive

Lua "..." args

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


A minor feature request.
It would be nice if, when I have a method using variable args, I
could pass those args along to another function with the "..." syntax.
Example:
function SomeObject:myMethod(blah, ...)
 return anotherObject:anotherMethod(...)
end
Instead of the uglier and more limited way:
function SomeObject:myMethod(blah, ...)
 local argCount = tableLength(arg)
 if ( argCount == 0 ) then
	return anotherObject:anotherMethod(forwardMethod)
 end
 if ( argCount == 1 ) then
	return anotherObject:anotherMethod(forwardMethod, arg[1])
 end
 if ( argCount == 2 ) then
	return anotherObject:anotherMethod(forwardMethod, arg[1], arg[2])
 end
 if ( argCount == 3 ) then
	return anotherObject:anotherMethod(forwardMethod, arg[1], arg[2], arg[3])
 end
end

AltStyle によって変換されたページ (->オリジナル) /