[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: tremove oddity
- From: paul@...
- Date: Fri, 28 Sep 2001 12:01:35 +0800
The following code:
a = { "a", "b", "c" }
for i, v in a do write(v) end
tremove(a)
for i, v in a do write(v) end
foreach
produces "abcab2" as the result.
Then I checked the Lua manual, "tremove" removes the last element and
then inserts extra field "n = getn(table)". But this makes
the array table into a mapping table. I mean, is this a desirable
behavior? for any good reasons?
Tentatively, I change to foreachi in my programs, but writing extra
anonymous function isn't as clean, as I am forced to use upper values :PP
Regards,
.paul.