Blackplug
|
  |
| Joined: 06 Dec 2010 |
| Total Posts: 1714 |
|
|
| 20 Jun 2012 02:42 AM |
| Can you give me an example of how to use them? |
|
|
| Report Abuse |
|
|
FPGA
|
  |
| Joined: 05 May 2012 |
| Total Posts: 372 |
|
|
| 20 Jun 2012 02:43 AM |
function f(...) t = {...} -- t is a table containing all arguments to f end |
|
|
| Report Abuse |
|
|
redditor
|
  |
| Joined: 26 Jul 2011 |
| Total Posts: 182 |
|
|
| 20 Jun 2012 04:47 AM |
| They're pretty cool. I just haven't found a use for them. That or fpga and I have no idea what either of us are talking about. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2012 07:46 AM |
local function tableMerge(...) local tables = {...} local output = {} for _, input in pairs(tables) do for _, element in pairs(input) do table.insert(output, element) end end return output end
print(table.concat(tableMerge({1,2,3}, {4}, {5,6,99}))) |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2012 01:20 PM |
It's for functions with a dynamic number of inputs.
|
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 20 Jun 2012 02:09 PM |
local printl=print function print(...) printl(...) end |
|
|
| Report Abuse |
|
|
lombardo2
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 1604 |
|
|
| 20 Jun 2012 02:13 PM |
| Yeah I think varargs refers to Variable arguments, in lua we use ... to declare that |
|
|
| Report Abuse |
|
|