Home Segments Index Top Previous Next

239: Mainline

Suppose, for example, that you want to define isVegetable, a predicate that determines whether a Food instance is also instance of the Vegetable class. First, you capture the fact that most Food instances are not instances of the Vegetable class by defining isVegetable for the Food class:

Food method definition • instance 
isVegetable 
  ^ false 

Next, you capture the fact that Vegetable instances are instances of the Vegetable class:

Vegetable method definition • instance 
isVegetable 
  ^ true