Sha256: 4942299cb1f71ce6e701d567a2c6a664e6ec443b932e1b1ead2318e94021f366
Contents?: true
Size: 280 Bytes
Versions: 16
Compression:
Stored size: 280 Bytes
Contents
module Enumerable # Uses #+ to sum the enumerated elements. # # [1,2,3].sum #=> 6 # [3,3,3].sum #=> 9 # def sum(identity = 0, &block) if block_given? map(&block).sum else inject{ |sum, element| sum + element } || identity end end end
Version data entries
16 entries across 15 versions & 1 rubygems