In a large code base I'm working on, some colleagues use double negation in their boolean logic:
if (!!variable && (!!api.lookup("some-string"))) {
do_some_stuff();
}
My guess is: they are trying to ensure that the value being evaluated is the actual boolean representation, so they negate it, then negate that again to get it back to its actual boolean value.
Is this correct, or am I missing something?
It's a trick to convert to bool.