Sha256: 596d70ea64ab7fd6f2d75b18a65706a1083f5a417389987bc0d99218560caeb9
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
module Polyfill module V2_4 module Enumerable module Instance module Sum module Method def sum(init = 0) acc = begin init.dup rescue TypeError init end each do |elem| acc += block_given? ? yield(elem) : elem end acc end end refine ::Dir do include Method end refine ::Enumerator do include Method end refine ::Hash do include Method end refine ::IO do include Method end refine ::Range do include Method end refine ::StringIO do include Method end refine ::Struct do include Method end def self.included(base) base.include Method end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
polyfill-0.6.0 | lib/polyfill/v2_4/enumerable/instance/sum.rb |
polyfill-0.5.0 | lib/polyfill/v2_4/enumerable/instance/sum.rb |
polyfill-0.4.0 | lib/polyfill/v2_4/enumerable/instance/sum.rb |