lua-users home
lua-l archive

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


>  Hi,
> 
>   I would like to write something like this *in a single line*:
> 
> y = (x == nil)? x: x + 1
> 
>   [...]
> 
>   I'm not seeing the solution. Is this possible?

y = x and x + 1   ?

(I am assuming that x cannot be 'false', as that would raise an error
in your code.)

-- Roberto