[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lua-l
Subject:    Re: bug report: LUA compiler glitch
From:       Rob Kendrick <rjek () rjek ! com>
Date:       2011-08-11 9:29:53
Message-ID: 20110811092953.GA5370 () rjek ! com
[Download RAW message or body]

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.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic