Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 629
user1766438 Avatar asked Dec 06 '25 02:12

user1766438


1 Answers

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.

like image 175
Spar Avatar answered Dec 08 '25 21:12

Spar