Rules / Types, classes & roles / domain-specific

Order Reference

Human readable form for comparison operators.

What it is #

Routines #

Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.

infix cmp #

multi infix:<cmp>(\a, \b --> Order:D)

Returns Order:D.

cmp will first try to compare operands as strings (via coercion to Stringy), and, failing that, will try to compare numerically via the <=> operator or any other type-appropriate comparison operator. See also the documentation for the cmp operator.

infix C«<=>» #

multi infix:«<=>»(Int:D \a, Int:D \b --> Order:D) Specialized form for Int.

Examples, run three ways #

Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.

1 no-output

enum Order (:Less(-1), :Same(0), :More(1));

Not executed: the documentation states no expected output for this example.