go to previous page   go to home page   go to next page

Answer:

Ideally not. The operation of a loop should be apparent in the condition of the while or for statement, not hidden somewhere in the body of the loop.


Special Cases First

Often a function with early returns looks like this:

xxx function ( aaa, bbb, ccc )
{
  if ( special_case_1 ) return www ;
  
  if ( special_case_2 ) return yyy ;
  
  . . . .
  
  set_up_for_loop ;
  
  while ( general_case )
  {
     ...
  }
  
  return zzz;
}


QUESTION 6:

What familiar form does the loop in the above follow?