lua-users home
lua-l archive

Re: BUG in table.concat

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


On Jun 29, 2008, at 12:54 AM, Leo Razoumov wrote:
print( table.concat({[1]=1, [2]=2, [4]=4}, '/') )
stdin:1: bad argument #1 to 'concat' (table contains non-strings)
Well... table.concat works "Given an array where all elements are strings or numbers"... nil is neither a string nor a number...
http://www.lua.org/manual/5.1/manual.html#pdf-table.concat
So...
local aList = { 1, 2, nil, 4 }
-- works
print( table.concat( aList, '/', 1, 2 ) )
-- raises an exception
print( table.concat( aList, '/', 1, 3 ) )
In other words... go with the flow... not against it :)
--
PA.
http://alt.textdrive.com/nanoki/

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