lua-users home
lua-l archive

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

On Wed, Aug 10, 2011 at 02:14:37AM +0200, Steve Litt wrote:
> Can anyone explain the benefit of:
> a, b = 1, 2

It's occasionally useful to aid program readability, as in this
sort of situation: 
    r = sqrt(x^2+y^2)
    c, s = x/r, y/r

where you are in effect working with vectors, but it is convenient 
to have named rather than numerically indexed coordinates;

or this:

    if x[i]>M then  
        j, M = i, x[i]  

i.e. j and M are associated as closely and in the same way as i and 

But it does not aid readability to do e.g. this:

    Churchill, answer_to_life_etc = "British statesman", 42