previous | index | next

Flow of Control

The function could also be written:

bool increasingOnIntegerRange(int f(int), 
                              int low, 
                              int high) {
    if ( low == high )
        return true;
    if ( f(low) < f(low+1) )
        return increasingOnIntegerRange(f, 
                                        low+1, 
                                        high);
    return false;
}

Q: Why can the else keyword be omitted?

A: The else keyword is used to ensure that exactly one of three alternatives are taken.

     When each alternative is to return out of the statement, this behavior is ensured even without the else's.


previous | index | next