Do you know where your variables are? | |
PerlMonks |
Re: Factory Pattern in Perl6by raiph (Deacon) |
on May 14, 2016 at 03:26 UTC ( [id://1163016]=note: print w/replies, xml ) | Need Help?? |
(update: my first guess was wrong. See rest of this thread.)
My first guess is that your class declarations (which you didn't list) declare attributes without a public accessor rather than with one (ie you're using has $!foo instead of has $.foo). The official docs touch on this here. I'll discuss this more if it turns out to be the issue and you reply here requesting more info.
You didn't include enough code for me to confidently figure out what's going wrong. The first method works for me:
This displays:
A Positional container as declared by my @args inserts positional arguments into an argument list. The "Default constructor ... only takes named arguments" comes up if you call a .new method that, through inheritance, calls the positional argument version of the new method from the root class Mu, eg:
If you want a constructor that takes positional arguments you have to write one yourself like this one declared in the Duration class shipped with Perl 6:
So the Duration class's .new can accept a positional argument, eg:
Hopefully that's of some use.
»ö« . o O ( "the celebrity tell-all of the Perl-6 cult?" )
In Section
Seekers of Perl Wisdom
|
|