Is this what you're looking for? class MattTest { has Str $.string; submethod BUILD (:$string) { ## submethod BUILD is the constructor ## :$string is a named argument "string" say "passed $string"; } }
my $test = MattTest(:string('abc')); # Check to see the class is the right kind of thing: say $test.WHAT # Output the class as a readable string say $test.perl; ----- Original Message ---- From: Matthew Keene <[EMAIL PROTECTED]> To: perl6-compiler@perl.org Sent: Tuesday, May 15, 2007 5:02:56 AM Subject: Error calling bless in non-default constructor I'm trying to use a non-default constructor for a class under Pugs 6.2.13, like so class MattTest { sub new (Class $class : Str $string) { say "Passed $string to the constructor for $class" ; return $class.bless ; } } my $test = MattTest.new('abc') ; This is failing with the following output: D:\Apps\Perl6>pugs ConstructorTest.p6 Passed abc to the constructor for MattTest *** No such method in class MattTest: "&bless" at ConstructorTest.p6 line 5, column 12-25 Am I doing something wrong, or is bless currently unimplemented in Pugs, or is something else wrong. I have more or less copied the code for the constructor from the test in oo/construction.t. --------------------------------- How would you spend $50,000 to create a more sustainable environment in Australia? Go to Yahoo!7 Answers and share your idea. ____________________________________________________________________________________Get the free Yahoo! toolbar and rest assured with the added security of spyware protection. http://new.toolbar.yahoo.com/toolbar/features/norton/index.php