George Larson wrote:

> That's an interesting subject that I've never considered.
> 
> I usually return immediately.  For me, it makes the code easier to
> read.  I work with a number of other coders here and, if the result
> isn't returned then I have to keep reading through the code to make
> sure nothing else is done with it.  However, when I see the 'return'
> then I know we're done there.

I tend to try to have just one return point, but I will occasionally
have more, typically when a function returns more than just true or
false.  
If it's a true or false outcome, but I still have multiple failure
points, I'll sometimes use a construct like this:


rc=0;
while(true){

  if ( cond1 ) { errormsg; rc=1; break; }
  if ( cond2 ) { errormsg; rc=1; break; }
  if ( cond3 ) { errormsg; rc=1; break; }
  if ( cond4 ) { errormsg; rc=1; break; }
  if ( cond5 ) { errormsg; rc=1; break; }
  if ( cond6 ) { errormsg; rc=1; break; }
  if ( cond7 ) { errormsg; rc=1; break; }

  break;
}

return rc;



-- 
Per Jessen, Zürich (16.6°C)


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to