📘 Method postfix operator . in Perl 6

📘 Method postfix operator . in Raku

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


There are a few syntactical elements in Perl 6, which start with a dot. These operators might look like a postfix operator, but they all are the forms of the calling a method on an object. Unlike Perl 5, the dot operator does not do any string concatenation.

.method calls a method on a variable. This works with both real objects and with those variables, which are not instances of any class, for example, built-in types like integers.

say "0.0".Numeric; # 0
say 42.Bool;       # True 

class C {
    method m() {say "m()"}
}
my $c = C.new;
$c.m(); # m()

Leave a Reply