Implement Array#each

Submitted By:
nilbus2

Difficulty:
Medium

Tags:
enumerables

Instructions:
Re-implement Ruby's each method without using each (or for, which is really just each).

Code:
class Array
  def each
    ___
  end
end

a = [rand, rand, rand]
assert_equal a.each{}, a

b = []
a.each { |e| b << e }
assert_equal a, b

Your Solution

Ruby 1.9.3

Back to Problems