Welcome Guest, Not a member yet? Register   Sign In
Avoiding nesting everything inside IF statements
#7

[eluser]John_Betong[/eluser]
 
One way I came across to reduce the else statements was to supply a default value:
[code]

function to_reduce_indentation()
{
$result = '#cfc'; // $alternate bg_colour

if ( (FALSE_CONDITION) )
{
$result = '#cff';
}

return $result;
}
 
And yes I endeavout to have a single exit point since it makes debugging an awful lot easier to temporaily hard-code the return value.
 
 
 
Just noticed there is no spell checker in the "Fast Reply".
 
 


Messages In This Thread
Avoiding nesting everything inside IF statements - by El Forum - 09-29-2009, 08:46 AM
Avoiding nesting everything inside IF statements - by El Forum - 09-29-2009, 09:06 AM
Avoiding nesting everything inside IF statements - by El Forum - 09-29-2009, 09:26 AM
Avoiding nesting everything inside IF statements - by El Forum - 09-29-2009, 09:34 AM
Avoiding nesting everything inside IF statements - by El Forum - 09-29-2009, 01:00 PM
Avoiding nesting everything inside IF statements - by El Forum - 09-29-2009, 04:26 PM
Avoiding nesting everything inside IF statements - by El Forum - 09-29-2009, 06:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB