Eiffel "Gotchas"

07 April 1998


Oops!

Gotcha #3 - 'min', 'max' and tennis players

What's wrong with this routine? It's supposed to print the object_id of two COMPARABLE objects in ascending comparable order (not ascending object_id order).

   print_ascending(c1: COMPARABLE; c2: like c1) is
      require
         not_void: c1 /= void and c2 /= void
      do
         print( c1.min(c2).object_id.out )
         print( c1.max(c2).object_id.out )
      end

(Don't worry about incidentals like the lack of newlines in the output format)

ANSWER


Eiffel and NICE are registered trademarks of the Nonprofit International Consortium for Eiffel.

Eiffel "Gotchas"