Rewriting Expressions
Discover how the comparison expressions trigger a compiler to generate the spaceship expression.
We'll cover the following...
When the compiler sees something such as a < b
, it rewrites it to (a <=> b) < 0
using the spaceship operator. Of course, the rule applies to all six comparison operators:
a OP b
becomes (a <=> b) OP 0
. It’s even better. If there is no ...