Re: How to improve speed of returning value from calling method on an array of objects?
- From: a.r.ferreira@xxxxxxxxx (Adriano Ferreira)
- Date: Fri, 6 Jan 2006 13:44:08 -0200
On 1/6/06, Sai Tong <stong@xxxxxxxxxxxxxxxxxxx> wrote:
> I have an array of many objects and I want to call a method on
> each of these objects and the save the returned values into an array:
> my @return_values;
> foreach my $retrievedObject (@array_of_objects) {
> push (@return_values , $retrievedObject->method );
> }
Maybe you can use C<map>
my @return_values = map { $_->method } @array_of_objects;
But that's not going to be fast (as well as the for construction) if
the repeated calls of C<$_->method> aren't fast enough (for your
purposes).
Adriano.
.
- Follow-Ups:
- References:
- Prev by Date: How to improve speed of returning value from calling method on an array of objects?
- Next by Date: Active Perl - PPM Question
- Previous by thread: How to improve speed of returning value from calling method on an array of objects?
- Next by thread: Re: How to improve speed of returning value from calling method on an array of objects?
- Index(es):
Relevant Pages
|