Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/perl6/doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Mouq committed Feb 17, 2014
2 parents 9f194bf + 76044ba commit 80fc869
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/classtut.pod
Expand Up @@ -14,7 +14,7 @@ result is interesting and, at times, useful.
has Bool $.done;
method new(&callback, Task *@dependencies) {
return self.bless(*, :&callback, :@dependencies);
return self.bless(:&callback, :@dependencies);
}
method add-dependency(Task $dependency) {
Expand Down Expand Up @@ -237,7 +237,7 @@ this example does:
=for code
method new(&callback, Task *@dependencies) {
return self.bless(*, :&callback, :@dependencies);
return self.bless(:&callback, :@dependencies);
}
X<|objects, bless>
Expand All @@ -247,10 +247,8 @@ The biggest difference between constructors in Perl 6 and constructors in
languages such as C# and Java is that rather than setting up state on a somehow
already magically created object, Perl 6 constructors actually create the
object themselves. This easiest way to do this is by calling the L<bless>
method, also inherited from L<Mu>. The C<bless> method expects a positional
parameter--the so-called I<candidate>--and a set of named parameters providing
the initial values for each attribute. The C<*> as a candidate tells C<bless>
to create a new object and initialize it.
method, also inherited from L<Mu>. The C<bless> method expects a set of named parameters providing
the initial values for each attribute.
The example's constructor turns positional arguments into named arguments, so
that the class can provide a nice constructor for its users. The first
Expand Down Expand Up @@ -409,7 +407,7 @@ significant improvement over Perl 5's approach to handling multiple inheritance.
method new( *%params ) {
%params<cookbooks> //= []; # remove once Rakudo fully supports autovivification
push( %params<cookbooks>, "Cooking for Geeks" );
return self.bless(*, |%params);
return self.bless(|%params);
}
}
Expand Down

0 comments on commit 80fc869

Please sign in to comment.