Operators

Equivalence & identity — eqv / ===

Full

Compare structure (eqv) or object identity (===), beyond value equality.

Beyond == (numeric) and eq (string), Raku has eqv for structural equivalence and === for identity. They answer "are these the same shape?" and "are these the same value?" rather than just "do they compare equal?".

eqv — same type and structure #

eqv is true when two values have the same type and the same contents, all the way down — so two lists match only if their elements match in order.

say (1, 2, 3) eqv (1, 2, 3);
say [1, 2] eqv [1, 3];
Output
True
False

=== — value identity #

=== tests whether two things are the same value (immutables) or the very same object (mutables).

say 5 === 5;
say "a" === "a";
Output
True
True

Two 5s and two "a"s are the same immutable value, so === is True.

Notes #