Inverted Spaceship Results¶
In the first class, the properties are declared $a, then $b. Comparing the values with spaceship leads to 1, -1.
In the first class, the properties are declared $b, then $a. The rest of the code is the same. Comparing the values with spaceship leads to -1, 1.
This phenomenon disappears when using promoted properties.
See Also¶
Order of properties matter [Try me]