Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/compat.rb

Instance Method Summary collapse

Instance Method Details

#sum(&block) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/solargraph/compat.rb', line 27

def sum &block
  inject(0) do |s, x|
    if block
      s + block.call(x)
    else
      s + x
    end
  end
end