On Mon, Jan 12, 2009 at 03:30:05PM -0800, Ovid wrote:
> > From: Larry Wall <la...@wall.org>
> > :   my @array = '   foo   ', '   bar  ';
> > :   @array .= trim;
> > :   say @array.perl;
> > :  
> > : And what if I have an array of hashes of hashes of arrays?
> > : 
> > : Currently you can call 'trim' on arrays, but it's a no-op.  
> > : Similar issues with chomp and friends.
> >
> > It should probably say "No such method".  

S29 doesn't document .trim, but like other similar methods I
would expect it to be defined on C<Any>.  If so, I would
expect the output of the above to be  C< ["foo      bar"]\n >.

> > We have hyperops now to apply
> > scalar operators to composite values explicitly:
> > 
> >     @array».=trim
> 
> Won't that fail with 'No such method' on an array of hashes? 
> Or are hyperops applied recursively?

I would expect this to be roughly equivalent to:

    for @array { $_ .= trim; }

For an array of hashes, this would result in each hash element
of @array being replaced with a reference to an array of the 
trimmed string representation of the hash.

Pm

Reply via email to