# File activesupport/lib/active_support/core_ext/enumerable.rb, line 57
def sum(identity = nil, &block)
if identity
_original_sum_with_required_identity(identity, &block)
elsif block_given?
map(&block).sum
# we check `first(1) == []` to check if we have an
# empty Enumerable; checking `empty?` would return
# true for `[nil]`, which we want to deprecate to
# keep consistent with Ruby
elsif first.is_a?(Numeric) || first(1) == []
identity ||= 0
_original_sum_with_required_identity(identity, &block)
else
ActiveSupport::Deprecation.warn( Rails 7.0 has deprecated Enumerable.sum in favor of Ruby's native implementation available since 2.4. Sum of non-numeric elements requires an initial argument..squish)
inject(:+) || 0
end
end