Case Analysis, cont.
Example 1
/* Let x be the absolute value of y. */
if ( y < 0 )
/* Let x be -y. */
. . .
else
/* Let x be y. */
. . .
Example 2
/* Let x be the absolute value of y. */
x = Math.abs(y);
I.e., sometimes case analysis is counter-productive and there is a uniform way to solve the problem.
Previous slide
Next slide
Back to first slide
View graphic version