return foo == null ? true : false; return foo == null ? true : false;"Hmmm, if 'foo == null' is true, than it's true... I see..."
Seriously..
function isAvailable(){ objInDb = findByName('Joan Carlos'); // the object or false
return objInDb ? true : false;
}But all this could be because I'm a noob in a language I don't really know... Php that magical land where nothing is what it looks like and is always ready to stab you in the back, can't say I'm a fan of it... Or dynamic languages, or anything magical... Ok, I'm going to places I don't want to remember, sorry...
return foo ? true : false;
or even return foo == true ? true : false;You are missing the point, which is it's really silly to transpose a boolean into a boolean using a ternary operator.
If you want to argue that "foo == null" is the problem due implicit nil value falseness, than the solution is simply to use strict comparison operator "===", transposing "foo == null" into a boolean doesn't solve the falseness issue if you think this is what the original author was trying to address.