๐Ÿ“˜ 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

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