Permalink
Browse files

[FIX] GeekCook example works on rakudo now

GeekCook.new hat two issues. First, the return self.bless got the wrong
parameters. Thus, it did not return the right object.

Also, it pushes onto %params<cookbooks> which might be undef. In rakudo this
does not enough autovivification (whatever the verb is) to make this push
possible. Therefore, the hash element needs to be initialised. It's not nice
to have a workaround for unimplemented functions but having an example that
does not work is certainly worse.
  • Loading branch information...
1 parent 3c9cdd9 commit 6f6af1136f1b48daa884a3d064c20f06d7007f6a @Caldrin Caldrin committed Aug 18, 2011
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/classes-and-objects.pod
@@ -459,8 +459,9 @@ significant improvement over Perl 5's approach to handling multiple inheritance.
class GeekCook is Programmer is Cook {
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);
}
}

0 comments on commit 6f6af11

Please sign in to comment.