Skip to content

Commit

Permalink
Improves a bit the inheritance example. Closes #620
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed May 4, 2018
1 parent 33fab2f commit bc6130b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions doc/Language/classtut.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -474,19 +474,15 @@ other means, such as attribute accessors.
=begin code
class Employee {
has $.salary;
method pay() {
say "Here is \$$.salary";
}
}
class Programmer is Employee {
has @.known_languages is rw;
has $.favorite_editor;
method code_to_solve( $problem ) {
say "Solving $problem using $.favorite_editor in "
~ $.known_languages[0] ~ '.';
return "Solving $problem using $.favorite_editor in "
~ $.known_languages[0];
}
}
=end code
Expand All @@ -501,8 +497,8 @@ defined in the Employee class as though they were from the Programmer class.
favorite_editor => 'vim'
);
$programmer.code_to_solve('halting problem');
$programmer.pay();
say $programmer.code_to_solve('halting problem'), " will get ", $programmer.salary(), "\$";
#OUTPUT: «Solving halting problem using vim in Perl5 will get 100000$␤»
=end code
=head2 Overriding inherited methods
Expand Down

0 comments on commit bc6130b

Please sign in to comment.