According to the 6.d (current version) check list, they can.
However,
class Foo {
has num $.numillo;
submethod BUILD( :$numillo = 3.5 ) {}
};
my $foo = Foo.new;
say $foo.raku; # OUTPUT: «Foo.new(numillo => 0e0)»
The atttribute does not seem to be bindable, or at least does not get a value assigned. Am I missing something here?
You are just assigning a value to a named parameter in BUILD
, not to the attribute!
submethod BUILD( :$!numillo = 3.5e0 ) {}
should fix that (note the ! in the signature). Please also note that 3.5
is not a num
, you would have to make it one by adding e0
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With