Ordering
t
RESCRIPT
type t = floatOrdering values represent the result of a comparison: less, equal, or greater.
less
RESCRIPT
let less: floatequal
RESCRIPT
let equal: floatgreater
RESCRIPT
let greater: floatisLess
RESCRIPT
let isLess: float => boolisLess(ordering) returns true when ordering equals Ordering.less.
Examples
RESCRIPTOrdering.isLess(Ordering.less) == true
Ordering.isLess(Ordering.equal) == false
isEqual
RESCRIPT
let isEqual: float => boolisEqual(ordering) returns true when ordering equals Ordering.equal.
Examples
RESCRIPTOrdering.isEqual(Ordering.equal) == true
Ordering.isEqual(Ordering.greater) == false
isGreater
RESCRIPT
let isGreater: float => boolisGreater(ordering) returns true when ordering equals Ordering.greater.
Examples
RESCRIPTOrdering.isGreater(Ordering.greater) == true
Ordering.isGreater(Ordering.less) == false
invert
RESCRIPT
let invert: float => floatinvert(ordering) flips the ordering result (less becomes greater and vice versa).
Examples
RESCRIPTOrdering.invert(Ordering.less) == Ordering.greater
Ordering.invert(Ordering.equal) == Ordering.equal
fromInt
RESCRIPT
let fromInt: int => floatfromInt(n) converts an integer comparison result into an ordering.
Examples
RESCRIPTOrdering.fromInt(-5) == Ordering.less
Ordering.fromInt(0) == Ordering.equal
Ordering.fromInt(3) == Ordering.greater
ignore
RESCRIPT
let ignore: t => unitignore(ordering) ignores the provided ordering and returns unit.
This helper is useful when you want to discard a value (for example, the result of an operation with side effects) without having to store or process it further.