WTF comes from trying to plan for worse case scenarios.
I did not write this. My doppleganger did :)
var WorstCaseSenario:*=" 0x00 ";
trace(toBoolean(WorstCaseSenario) == false);
function toBoolean(bool:*):Boolean
{
if (bool == "" || !bool) {
return false;
}
if (bool is Bool
This remainds me of a utility method written by a former coworker at my
previous job, that rightfully belongs in the daily WTF.
public static function mtd_validarVar (variable : Object) :Boolean
{
if (
variable == false ||
variable == undefined ||
variable == ""||
variable == null
some great optimalistations can be found here:
http://mindprod.com/jgloss/unmain.html
for ex.
class Truth
{
boolean isTrue ( boolean assertion )
{
if ( assertion != false )
{
return assertion;
}
else
{
return assertion;
}
}
3 matches
Mail list logo