3 ms·
I did something of this kind recently and it was to enforce more of an api in my object, like internally I call some low api method that either gives me the obj
by diaz 13y ago
I did something of this kind recently and it was to enforce more of an api in my object, like internally I call some low api method that either gives me the object I'm looking for or false / null when doesn't find it, but in my interface I don't want to leak that object, just true or false. So
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...
- EpicEng 13y agoI this case, returning objInDb would be semantically different. So, if you always want to return a Boolean, you did the right thing.