lua-users home
lua-l archive

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

The following code:

	a = { "a", "b", "c" }
	for i, v in a do write(v) end
	for i, v in a do write(v) end

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