doc for table.concat is slightly misleading
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: doc for table.concat is slightly misleading
- From: David Jones <drj@...>
- Date: 2006年8月16日 16:52:30 +0100
The documentation for table.concat implies that table.concat{x,y,z}
is equivalent to x .. y .. z, but this isn't so when metatables are
involved:
> t = setmetatable({}, { __concat = function(x, y)return x.x .. y
end })
> t.x='foo'
> print(t .. 1 .. 1)
foo11
> table.concat{t,1,1}
stdin:1: bad argument #1 to 'concat' (table contains non-strings)
stack traceback:
[C]: in function 'concat'
stdin:1: in main chunk
[C]: ?
Personally, as someone who doesn't do much string manipulation in
Lua, I'd be equally happy with either a doc change or a behaviour
change.
drj