lua-users home
lua-l archive

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

David Olofson <> wrote:
(27/02/2005 22:03)

>The tricky part is avoiding a dummy initialization before code like 
>        //y = 0;   // No, thanks!
>        if a
>                y = 1;
>        else
>                y = 2;

David, did you mean 'No thanks' as in: not wanting the ugly extra assignment to zero?

In a case like this, I use this:

	y = 2
	if a then  y = 1  end

Only two, no 'else' and no chance of a var depending on a conditional branch merely for its prior existence...