📘 Universal comparison operator === in Perl 6

=== 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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s