Documentation for infix ===, infix ⩶
assembled from the following pages:
Language documentation: Operators §
From Operators
(Operators) infix ===, infix ⩶ §
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 types say 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 ValueObjAt object that won't change for the lifetime of the object.
Since Rakudo version 2021.07, ⩶ is an alias for this operator.