lua-users home
lua-l archive

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


On Tue, Aug 09, 2011 at 08:14:37PM -0400, Steve Litt wrote:

> Can anyone explain the benefit of:
> 
> a, b = 1, 2
> 
> The only place I've seen the slightest benefit of that was when 
> capturing the return of functions returning multiple values.

I suspect it's a convinces that falls out of the wash due to the way the
rest of Lua works.  I find using it with "local" and such to be much
more succinct and readable than setting each variable individually.

It's also useful for swapping things without a temporary variable:

t = { "foo", "bar" }
t[1], t[2] = t[2], t[1]

B.