Operators
Equivalence & identity — eqv / ===
FullCompare 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
TrueTwo 5s and two "a"s are the same immutable value, so === is True.
Notes #
==/eqcompare values after coercion (1 == 1.0isTrue);eqvrequires the same type too (1 eqv 1.0isFalse).- For containers,
===compares object identity: two separately-built arrays with equal contents areeqvbut not===. =:=is the third, rarest one — it tests whether two variables are bound to the same container, not just equal values.