Skip to content

Commit bc6130b

Browse files
committed
Improves a bit the inheritance example. Closes #620
1 parent 33fab2f commit bc6130b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

doc/Language/classtut.pod6

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,19 +474,15 @@ other means, such as attribute accessors.
474474
=begin code
475475
class Employee {
476476
has $.salary;
477-
478-
method pay() {
479-
say "Here is \$$.salary";
480-
}
481477
}
482478
483479
class Programmer is Employee {
484480
has @.known_languages is rw;
485481
has $.favorite_editor;
486482
487483
method code_to_solve( $problem ) {
488-
say "Solving $problem using $.favorite_editor in "
489-
~ $.known_languages[0] ~ '.';
484+
return "Solving $problem using $.favorite_editor in "
485+
~ $.known_languages[0];
490486
}
491487
}
492488
=end code
@@ -501,8 +497,8 @@ defined in the Employee class as though they were from the Programmer class.
501497
favorite_editor => 'vim'
502498
);
503499
504-
$programmer.code_to_solve('halting problem');
505-
$programmer.pay();
500+
say $programmer.code_to_solve('halting problem'), " will get ", $programmer.salary(), "\$";
501+
#OUTPUT: «Solving halting problem using vim in Perl5 will get 100000$␤»
506502
=end code
507503
508504
=head2 Overriding inherited methods

0 commit comments

Comments
 (0)