4 ms·
As a C programmer, the idea that comparisons are only made in loops or ifs is very alien. Something like const bool press = (evt->flags & EVT_FLAG_PRESS)
by unwind 7y ago
As a C programmer, the idea that comparisons are only made in loops or ifs is very alien.
Something like
const bool press = (evt->flags & EVT_FLAG_PRESS) != 0;
is common, idiomatic and nice in my world (for some made-up key event handler).
- userbinator 7y agoI deal with similar code, although for me, "!= 0" is usually discouraged; I would just use the result of & in a condition later, or if it must be turned into 0 and 1, the "booleanise" operator: const bool press = !!(evt->flags & EVT_FLAG_PRESS);
- chkas 7y agoThere is no boolean data type in easylang, so it is only needed in conditions.