Quick actions

cmd+k|ctrl+k

Navigation

Languages

Tweak

Snippet info

Language

Raku

Visibility

public

Author

kaspik99

Created

2018-11-08T14:13:26Z

Updated

2018-11-08T14:13:26Z

use v6;

# https://opensource.com/article/18/11/how-make-perl-more-classy

class Answer {
    has Int $.x = 42;
    submethod TWEAK() {
        $!x = 666 if $!x == 314;  # 100 x pi is also bad
    }
}

my $a = Answer.new(x => 123);
say $a.x;

my $a2 = Answer.new(x => 314);
say $a2.x;
INFO