| ☞ | Program
Repair Shop ![]() |
57 |
136 sub copy_observers {
137 my ( $item_from, $item_to ) = @_;
138 my @from_observers = $item_from->get_observers;
139 foreach my $observer ( @from_observers ) {
140 $item_to->add_observer( $observer );
141 }
142 return scalar @from_observers;
143 }
add_observer can be used to add multiple observers
The author has apparently forgotten this
Here's my version:
sub copy_observers {
my ($from, $to) = @_;
$to->add_observer($from->get_observers);
}
I got the return value wrong here
My version returns the new number of observers on $to
Apparently it was supposed to return the old number in $from
Why?????
Fortunately, the test suite failed to detect this, so I ignored it
Thus sparing all of you a big noisy rant about inane function return values
| ☞ | ![]() |
☞ |