Sha256: 3bfd15ee95c84156bc45e1098a4a8d7799c48308309ccdd8a7be043b6a3edb8c

Contents?: true

Size: 279 Bytes

Versions: 3

Compression:

Stored size: 279 Bytes

Contents

module ArrayExtensions

  # from Active Support library
  def sum(identity = 0, &block)
    return identity unless size > 0

    if block_given?
      map(&block).sum
    else
      inject { |sum, element| sum + element }
    end
  end

end

Array.send :include, ArrayExtensions

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
ulla-0.9.9.2 lib/array_extensions.rb
semin-ulla-0.9.9.1 lib/array_extensions.rb
ulla-0.9.9.1 lib/array_extensions.rb