[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A very basic thing I don't get
- From: Wesley Smith <wesley.hoke@...>
- Date: Sat, 1 Oct 2011 10:31:24 -0700
For functions with multiple return values like pack, only 1 return
value is kept in a list of operations. It has confused me in the past
as well. Here's a more straightforward example:
-- will only return 2 values, not #x+1 values
function test(x)
return unpack(x), 1
end
Your example with {unpack(x), 1} is the same. Only the first value
form unpack is kept. The easiest way to do what you want is:
local vec4 = {unpack(vec3)}
vec4[4] = 1
wes
On Sat, Oct 1, 2011 at 10:25 AM, Thijs Koerselman
<thijskoerselman@gmail.com> wrote:
> I feel really stupid for asking this.
> local pos = {unpack({1,2,3}), 4}
> print("pos size ".. #pos)
> I would expect #pos to return 4, but instead its 2. A more real world
> situation would be to convert a vec3 to vec4 like this:
> local vec4 = {unpack(vec3), 1}
> What the heck am I missing?
> Thijs