lua-users home
lua-l archive

Re: Boolean matters

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


On 01/12/2012 20:50, Dirk Laurie wrote:
1. To convert a Lua value to boolean:
 bool = not not x
2. Exclusive or of Lua values x and y
 xor = not x == not y
Anything better?
(aside the (slight) formula error [1])
I never have any use for xor in practice. What examples usage do you have? (I really ask, i'm interested in knowing when & where we may need it, whether it is worth having it built in a prog lang).
Denis
[1] Of the kind I typically do myself, reason why I would rather code this KISS:
 x_xor_y = (x or y) and not (x and y)
Or: this is one usage case for Lua macros ;-)

AltStyle によって変換されたページ (->オリジナル) /