Default args in custom constructor
Suppose I have a class with a default attribute class Foo { has Int $.a = 1; } Now I want to write a custom constructor for it, with either `Foo.new()` or `Foo.new(3)` doing the obvious thing. Here's one way to do it: multi method new(Int $a = 1) { self.new(:$a); } but this duplicates t
Re: Default args in custom constructor
Have you considered hash flattening into argument lists yet? method new(Int $a) { my %args; with $a { %args<$a> = $a } self.bless(|%args); } Does that help you forward at all? - Timo