September 2017
Beginner
402 pages
9h 52m
English
The eqv operator tests whether its two operands are equivalent. The term assumes that both operands are of the same type and contain the same value. The following examples demonstrate the work of the operator.
Two integer values are equivalent:
my $a = 42;my $b = 42;say $a eqv $b; # True
If one of the values is of another type, say a string, then the result is False, even if the value can be converted to the same integer:
my $a = 42;my $c = "42";say $a eqv $c; # False
The eqv operator works with arrays, as shown in the following code:
my @a = 1, 2, 3;say @a eqv [1, 2, 3]; # True
And, with more complex data structures, say, with nested arrays. Consider the following code snippet:
my @b = [[1, 3], [2, 4]];say @b eqv ...