This project is archived and is in readonly mode.

#2489 ✓committed
Marc-André Lafortune

Enumerable#sum should not rely on size

Reported by Marc-André Lafortune | April 14th, 2009 @ 06:27 AM | in 2.3.4

Enumerable#sum should be valid for any Enumerable, not just those that respond_to? :size (like Array but unlike Range, for example).

My simple change maintains compatibility and doesn't rely on 'size'. I added a test attempting to sum a range which raises an exception with the previous definition of sum.

Thanks.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages