infix ===, infix ⩶

Documentation for infix ===, infix ⩶ assembled from the following types:

language documentation Operators

From Operators

(Operators) infix ===, infix ⩶

sub infix:<===>(AnyAny)

Value identity operator. Returns True if both arguments are the same object, disregarding any containerization.

my class A { };
my $a =;
say $a === $a;              # OUTPUT: «True␤» 
say ===;        # OUTPUT: «False␤» 
say A === A;                # OUTPUT: «True␤»

For value types, === behaves like eqv:

say 'a' === 'a';            # OUTPUT: «True␤» 
say 'a' === 'b';            # OUTPUT: «False␤» 
my $b = 'a';
say $b === '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.