Skip to content

Commit

Permalink
Correcting an error and expanding
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Jun 2, 2018
1 parent 29cd682 commit 9592264
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions doc/Language/classtut.pod6
Expand Up @@ -82,16 +82,18 @@ my $eat =
$eat.perform();
=end code
In this case, C<BUILD> is needed since C<bless> calls it with the two positional
arguments. With its signature, C<BUILD> converts the two positionals to the two
attributes, C<&!callback> and C<@!dependencies>, and returns the object (or
turns it in to the next phase, C<TWEAK>, if available).
In this case, C<BUILD> is needed since we have overriden the default new.
C<bless> is eventually (after calling C<BUILDALL>) invoking it with the two
named arguments that correspond to the two properties without a default value.
With its signature, C<BUILD> converts the two positionals to the two attributes,
C<&!callback> and C<@!dependencies>, and returns the object (or turns it in to
the next phase, C<TWEAK>, if available).
Declaring C<new> as a C<method> and not a C<multi method> prevents us from using
the default constructor which uses the attributes as named parameters. That is
one of the reasons why using C<new> is discouraged. If you need to declare it
anyway, use C<multi method new> if you do not want to disable the default
constructors.
the default constructor; tis implicit constructor uses the attributes as named
parameters. That is one of the reasons why using C<new> is discouraged. If you
need to declare it anyway, use C<multi method new> if you do not want to disable
the default constructors.
=head1 Starting with class
Expand Down

0 comments on commit 9592264

Please sign in to comment.