accumulate.rb

1
2
3
4
5
6
7
8
9
10
11
class Array
  def accumulate
    if block_given?
      result = []
      each { |x| result << yield(x) }
      result
    else
      enum_for(:accumulate) { size }
    end
  end
end

@remcopeereboom thinks this looks great

Comments

Now with enumerator.

helenst commented 12 April 2016 at 16:53 UTC

You're not logged in right now. Please login via GitHub to comment