-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enumerable#sum for empty array #247
Comments
Hmm... was my last generalization a bit too much? Have a look at the progression: However, there is a certain logic to it b/c now it accommodates any form of summation, i.e. any thing that responds to #+. So for instance What do you think? |
I think is´t ok, but change the example documentation in the method :) I changed to active_support #sum it works as yours did before. |
Ok, thanks. I updated the docs. Honestly I am on the fence about whether Enumerable#sum should be generic or useful only for numerics. |
Ruby 2.4 now includes |
Thanks. This is a bit unfortunate b/c I really believe the more generalized form is better. Yes, it means passing an argument, e.g. |
Ruby does have a few weird things in it. I'd suggest that we file a bug report on Ruby. To be honest, |
Ah, found this: https://bugs.ruby-lang.org/issues/12902 could be a good idea for us to chime in. |
I use Enumerable#sum a lot and just upgraded from version 2.9.3 to 3.0 and the behaviour changed.
[].sum should == 0 but i get nil instead.
The text was updated successfully, but these errors were encountered: