lua-users home
lua-l archive

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


Hi,

I've got bitten by a slight inconsistency when using table.concat()
with start and end indexes.  When providing just a start index,
table.concat() will happily return an empty string if that index is
out of range, but when providing both the start and the end,
table.concat() errors if the indexes are out of range.

This appears to be the same in 5.0 and 5.1 (so, consistent in that
sense, I guess).

I am wondering if this is intentional (i.e., a documentation issue),
or a bug?

$ lua-5.1
Lua 5.1.1  Copyright (C) 1994-2006 Lua.org, PUC-Rio
> t = { '1', '2' }
> = '"' .. table.concat(t, ',') .. '"'
"1,2"
> = '"' .. table.concat(t, ',', 2) .. '"'
"2"
> = '"' .. table.concat(t, ',', 3) .. '"'
""
> = '"' .. table.concat(t, ',', 2, 3) .. '"'
stdin:1: bad argument #1 to 'concat' (table contains non-strings)
stack traceback:
        [C]: in function 'concat'
        stdin:1: in main chunk
        [C]: ?
>

My assumption would be that the last example has a loop over the
indeces and results in the attempt of ..-ing nil.

Robby

--
r dot raschke at tombob dot com