Smalltalk Example
Here is an example, once again taken from the Smalltalk class hierarchy.
The code shown here occurs in class Magnitude. Recalling the earlier
subclasses, and the various different definitions of the less than operator,
we see that this one function can be used to
- See if an integer is between two values
- See if a real number is between two endpoints
- see if a character is between two other characters
- See if a string is between two other words in a dictionary
- See if a point is in a box bounded by two other points
There is one function, but a large number of different uses, all depending
upon the argument types.