Tom Christiansen wrote:
> 
> >   $sum = reduce {$_[0]+$_[1]} 0, @numbers || die "Chaos!!";
> 
> >Note with the || that way, it'll die immediately if @numbers is empty,
> >even before destroying the universe.
> 
> Yes, but why are you passing the size of the array in there?

'Cause I'm an idiot, apparently...

   $sum = reduce {$_[0]+$_[1]} 0, @numbers or die "Chaos!!";

That's better, assuming reduce() returns undef.

I'm gonna stop writing examples in emails because I always screw them
up...

-Nate

Reply via email to