Module: Enumerable
- Defined in:
- lib/task_tempest/active_support.rb
Instance Method Summary collapse
Instance Method Details
#sum(identity = 0, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/task_tempest/active_support.rb', line 20 def sum(identity = 0, &block) return identity unless size > 0 if block_given? map(&block).sum else inject { |sum, element| sum + element } end end |