lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo wrote:
And we'll probably fix this

Here is the fix:

I find myself using something I've dubbed the 'normalise' operator quite a lot in C and C++ --- !!.

bool convert_to_bool(int i)
{
    return !!i; // equivalent to (i ? true : false)
}

Yes, I know it's just two boolean nots one after the other, but it's sufficiently useful and IMO sufficiently atomic that it's worth thinking of as a primitive operation.

--
David Given
dg@cowlark.com