See Original text in context
sub infix:<===>(Any, Any)
Value identity operator. Returns True
if both arguments are the same object, disregarding any containerization.
my ;my = A.new;say === ; # OUTPUT: «True»say A.new === A.new; # OUTPUT: «False»say A === A; # OUTPUT: «True»
For value types, ===
behaves like eqv
:
say 'a' === 'a'; # OUTPUT: «True»say 'a' === 'b'; # OUTPUT: «False»my = 'a';say === 'a'; # OUTPUT: «True»# different typessay 1 === 1.0; # OUTPUT: «False»
===
uses the WHICH method to obtain the object identity.
If you want to create a class that should act as a value type, then that class must create an instance method WHICH
, that should return a value type object that won't change for the lifetime of the object.
Since Rakudo version 2021.07, the Unicode character ⩶ is an alias for this operator.