lua-users home
lua-l archive

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

>> - `for' statement for tables: «for k,v in t do ... end»
>Forgive me if this topic has already been beaten to death, but what is
>the advantage of this new syntax over the old foreach, such as:
>foreach(t, function(k,v) ... end)
>I suppose it eliminates the need to refer to upvalues with the "%"
>syntax, but what else?

Right, it avoids upvalues. And it also avoids the cost of a function call
per each element in the table.