Skip to content

#sum method breaks with Ruby 2.4 #44

Description

@moveson

Rails does some gymnastics to use the Enumerable#sum method built into Ruby 2.4+, and it falls back to the ActiveSupport Enumerable#sum method to handle situations in which the Ruby method doesn't handle it, such as an Array of Strings. Unfortunately, DescriptiveStatistics' #sum method gets in the way and breaks things when the Array is empty.

Using Ruby 2.4.2 and Rails 5.1.4 with descriptive_statistics 2.5.1:

>> [].sum
#> NoMethodError: undefined method `each' for nil:NilClass

See this post on StackOverflow for details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions