Search code examples
luaunpack

unpack() not available on Lua 5.4?


I am reading a few tutorials on Lua and am trying to figure out how to use unpack(). I found an example that goes like this:

t = { "the", "quick", "brown" }

print (unpack (t))

The output should be "the quick brown".
What actually happens is this: "stdin:1: attempt to call a nil value (global 'unpack')".

How can I make unpack() work?

My Info:
OS: Mac OS 10.8
Lua: 5.4.2


Solution

  • Since Lua 5.2 unpack function is now at table.unpack

    Function unpack was moved into the table library and therefore must be called as table.unpack.