tags:

views:

68

answers:

2

Hi all, just a quick check...

local var1, var2;

Is var2 a local variable here? Or is only var1 a local?

Thanks.

+3  A: 

Both are local.

lhf
A: 

Both variables are local. You can even assign both to nil:

local var1,var=nil

In this case, both are assigned to nil. To assign them to 2 different values, simply:

local var1,var=1,2
Valerio Schiavoni
All variables are `nil` unless you give them some other value. That first line doesn't do anything different than the line in the original question. You're explicitly putting `nil` into var1 and implicitly putting it into `var`. If it worked the way you're describing, then `var1, var2 = 1` would put `1` into both variables. This is not the case. `var1` would be `1` and `var2` would be `nil`.
Cogwheel - Matthew Orlando