Skip to content
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

Array#sum extension breaks on empty Arrays #34230

Closed
loganb opened this issue Oct 16, 2018 · 1 comment
Closed

Array#sum extension breaks on empty Arrays #34230

loganb opened this issue Oct 16, 2018 · 1 comment

Comments

@loganb
Copy link

loganb commented Oct 16, 2018

2.5.1 :001 > [].sum
 => 0
2.5.1 :002 > RUBY_VERSION
 => "2.5.1"
2.5.1 :021 > [].sum
Traceback (most recent call last):
        1: from (irb):21
ArgumentError (wrong number of arguments (given 1, expected 0))
2.5.1 :022 > Rails.version
 => "5.1.4"
2.5.1 :023 >

The reason is that the default arg to the extended sum method is nil and not 0.

@jeremy
Copy link
Member

jeremy commented Oct 16, 2018

Variant of #24796

@jeremy jeremy closed this as completed Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants