September 2017
Beginner
402 pages
9h 52m
English
The === operator is the value identity operator. For the scalar values, it gives the same results as the eqv operator—it returns true when both the types and the values of the operands are the same, as you can see here:
my $a = 42;my $b = 42;say $a === $b; # True
This is another example with a string and an integer:
my $a = 42;my $c = "42";say $a === $c; # False
For classes, the === operator returns True if both operands point to the same object, as shown in this example:
class O {}my $o1 = O.new();my $o2 = O.new();say $o1 === $o2; # False: same class but different objectsmy $o3 = $o1;say $o1 === $o3; # True: the same object
More on classes in Chapter 8, Object-Oriented Programming.
Read now
Unlock full access