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

  If I do this:

y = testfunc(x == nil, x, x+1)

  and implement the "if" inside the function, I have the problem that both expressions are evaluated before calling the function, and the second _expression_ will produce an error when x is nil.

  I'm not seeing the solution. Is this possible?

Thanks,
Scuri