Class: Array

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

Instance Method Summary collapse

Instance Method Details

#sum(&block) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/solargraph/compat.rb', line 13

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