lua-users home
lua-l archive

Re: Multiple assignment (was Bug report: LUA compiler glitch)

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Aug 11, 2011 at 2:08 AM, Philippe Lhoste <PhiLho@gmx.net> wrote:
>> On Wed, Aug 10, 2011 at 02:14:37AM +0200, Steve Litt wrote:
>>>
>>> Can anyone explain the benefit of:
>>>
>>> a, b = 1, 2
>
> Can also be useful for init:
> local a, b, c = 1, 1, 1
> because you cannot do:
> a = b = c = 1
> like in C.
>
> In other languages like Java, I put one variable per line, but in Lua, I am
> more informal...
Can also do reassignment of values, as in:
a, b = 1, 2
a, b = b, a
--> a == 2, b == 1
... without creating intermediary temporary variables.
Best regards,
Paul

AltStyle によって変換されたページ (->オリジナル) /