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

Answer:

Ideally not. The exit from a loop should be determined by the condition of the while or for.


Special Cases First

Often a function with early returns will look like this:

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


QUESTION 6:

What familiar form does the loop in the above follow?