lua-users home
lua-l archive

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


On 16 Oct 2013 16:43, "Mason Mackaman" <masondeanm@aol.com> wrote:
>
> The Lua website says that "Function unpack was moved into the table library and therefore must be called as table.unpack." I have Lua 5.2.2 and 'unpack' still works for me. Did they keep it around for back compatibility? Which one should I use?

`unpack` is only present in 5.2 of it's compiled with 5.1 compatibility enabled (i.e. LUA_COMPAT_UNPACK or LUA_COMPAT_ALL were defined).

If you're writing solely for 5.2, use `table.unpack`. If you're writing for 5.1 and 5.2, you can use `local unpack = unpack or table.unpack` at the top of the file and then call it as `unpack`.