Back Edit Delete

A data definition says TemperatureRange is either Integer[-10,10] or Integer[5,30]. Explain why this is a problematic itemization. Then explain what happens to the value 7 if a cond checks the -10-to-10 case before the 5-to-30 case.

Short answer

Accepted answer

The two subclasses overlap because values from 5 through 10 belong to both intervals. Therefore the data definition does not uniquely determine which subclass values such as 7 belong to. cond chooses the first true clause, so if Integer[-10,10] is checked first, 7 will always be handled by that branch. The data definition should normally be redesigned so the subclasses are unambiguous.