lua-users home
lua-l archive

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


2018-02-08 8:18 GMT+02:00 <Apeng.Xiong@alitech.com>:
>
> when I want to migrate to the new Lua, I faced the big problem is "table.getn" is no longer exist. so I still use Lua 5.1.
>

That is not Lua 5.1, that is Lua 5.0. To get it under 5.1, you need to
have compiled with the compatibiliy option,[1] which is the default,
so that's why people think table.getn is 5.1.

Anyway, it is the easiest possible thing to supply.

table.getn = function(t) return #t end

[1] "Function table.setn was deprecated. Function table.getn
corresponds to the new length operator (#); use the operator instead
of the function." From the "Changes in the Libraries" section of the
Lua 5.1 manual.