let's suppose I want to build a class that keeps track of the objects it
creates.
let's suppose that I want this class to be the base for a variety of
classes.
let's suppose that I decide, rather than fiddling with the default
constructor, to wrap it up.
something like:
class Animal {
our @.zoo;
&new.wrap( {
my @results = call();
push(@.zoo, @results[0]);
return @results;
} );
}
class Lion is Animal { ... }
class Tiger is Animal { ... }
class Panther is Animal { ... }
my $simba = Lion.new();
my $shere_khan = Tiger.new();
my $bagheera = Panther.new();
my @all = @Animal::zoo;
# @all should contain ($simba, $shere_khan, $bagheera);
will the above code work as expected, or is there something I've
overlooked?
cheers,
Aldo