📘 Universal comparison operator === in Perl 6

📘 Universal comparison operator === in Raku

N. B. Perl 6 has been renamed to Raku. Click to read more.


=== returns a True value if both operands are the same value. Otherwise, it returns False. This operator is also known as the value identity operator.

class I { } 

# Three different instances
my $i = I.new;
my $ii = I.new;
my $iii = I.new; 

my @a = ($i, $ii, $iii);
for @a -> $a {
    for @a -> $b {
        say $a === $b;
        # Prints True only when $a and $b are pointing
        # to the same element of the @a array. 
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Retype the CAPTCHA code from the image
Change the CAPTCHA codeSpeak the CAPTCHA code