[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Expanding an array out into a parameter list
- From: Wesley Smith <wesley.hoke@...>
- Date: Sun, 11 Sep 2011 15:54:46 -0700
> function foo (a, b)
> print ("You supplied " .. a .. " and " .. b)
> end
>
> I'd like to be able to store the function as one value, and all the
> parameters for a future call in another single value:
>
> -- store parameters for a future call to "foo(23, 42)"
> f = {func=foo, params={23, 42}}
>
> If I did this, how would I go about calling the function with my
> stored parameters? If I wrote "f.func(f.params)" it would be wrong;
would this work:
f.func(unpack(f.params))