Gmane
From: Carl Franks <fireartist <at> gmail.com>
Subject: construction clarification
Newsgroups: gmane.comp.lang.perl.perl6.language
Date: 2005-05-30 16:00:26 GMT (4 years, 5 weeks, 1 day, 7 hours and 39 minutes ago)
I have a class that normally takes a list of named arguments.
I also want to be able to handle a single argument.

class Foo {
  multi method new (Class $class: Str $date) {
    return $class.bless(date => $date);
  }

  submethod BUILD ($.date, $.time, $.offset) {
    # some error checking here
  }
}

my $foo = Foo.new('2005-05-30');

#
Is this the correct way to handle my scenario?
My explicit 'new' method should only handle the case of 
a single argument - otherwise the 'new' method 
inherited from Class will handle a list of named 
arguments.

My explicit BUILD submethod is called, regardless 
of which 'new' method is called, correct?

Cheers,
Carl