Class: Array
Instance Method Summary collapse
Instance Method Details
#sum_with_identity(identity = 0.0, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/classifier/extensions/vector.rb', line 9 def sum_with_identity(identity = 0.0, &block) return identity unless size.to_i.positive? if block_given? map(&block).sum_with_identity(identity) else compact.reduce(:+).to_f || identity.to_f end end |