Enumeration which embodies the result of a three-way comparison.
The problem with the Java style of comparing, which Scala also uses, is that you cannot easily compose comparisons. A typical comparison of two quantities compares the two most significant quantities, then, if the objects appear different, the result is returned; otherwise the result of the comparison of the less significant quantities is returned. This requires saving the value of the first comparison in a (final) variable. But yuck!
Comparisons compose lazily: orElse (and the short-circuit operators) only evaluate their other Comparison when needed. In many situations we use pattern-matching on the Comparison value.
NOTE: also that Comparison is a form of three-valued logic, in which More is true, Less is false and Same is indeterminate. That is the sense of &, |, &&, || and toInt, and of the Kleenean yielded by toKleenean.
NOTE: the cases are exported at the package level, so that they can be referred to simply as Same and Different.
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass Any