Module: Polyfill::V2_4::Enumerable
- Defined in:
- lib/polyfill/v2_4/enumerable.rb
Instance Method Summary collapse
Instance Method Details
#chunk ⇒ Object
8 9 10 11 12 |
# File 'lib/polyfill/v2_4/enumerable.rb', line 8 def chunk(*) return enum_for(:chunk) unless block_given? super end |
#sum(init = 0) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/polyfill/v2_4/enumerable.rb', line 14 def sum(init = 0) acc = init.dup each do |elem| acc += block_given? ? yield(elem) : elem end acc end |
#uniq ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/polyfill/v2_4/enumerable.rb', line 24 def uniq if block_given? to_a.uniq(&::Proc.new) else to_a.uniq end end |