遷移至五點一 |
|
function catchall( ... ) for i=1,arg.n do print( "Argument #", i, "is", arg[ i ] ) end -- Pass all arguments to another function show3( unpack( arg ) ) end function show3( a, b, c ) print( a, b, c ) end catchall( nil, 'two', nil ) --> Argument # 1 is nil --> Argument # 2 is two --> Argument # 3 is nil --> nil two nil
function catchall( ... ) -- Make a new table of values local theArguments = { ... } for i=1,select( '#', ... ) do print( "Argument #", i, "is", theArguments[ i ] ) end -- Pass all arguments to another function show3( ... ) end function show3( a, b, c ) print( a, b, c ) end catchall( nil, 'two', nil ) --> Argument # 1 is nil --> Argument # 2 is two --> Argument # 3 is nil --> nil two nil
ipairs()
會在第一個內嵌 nil
值處停止;#
(長度運算子)[可能會]在第一個內嵌 nil
值處停止;table.maxn()
會跳過內嵌 nil
值;但是select( '#', ... )
會讓你看到使用者傳入 後置 nil
值。
if (index < 0 && -index <= top) index = top+index+1; my* = luaL_check*(L, index, ...);
loadlib
時,使用 5.1 的 package.loadlib