lua-users home
lua-l archive

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

Mark Hamburg <mhamburg <at>> writes:

> A 5.2 request: It would be nice to have a mechanism/idiom to replace the
>     x or y
> idiom in cases where we want y if x is nil but not if x is false.

Incidentally, that was one of the earliest features
added to Perl 6:

  a || b    (returns b if a is 0, "", or undef)
  a // b    (returns b if a is undef)
I constantly feel the need for this when writing Perl.
But in Lua, the issue almost never comes up, mostly
because Lua thinks that 0 and "" are true.  Which is
wonderful, once you get used to it.