Reverse Array Using For

Submitted By:
shugo

Difficulty:
Medium

Tags:
arrays, for, loops

Instructions:
Implement the following method reverse using a for expression with no body.

Code:
def reverse(ary)
  result = []
  for ___ in ary
  end
  result
end

assert_equal ["baz", "bar", "foo"], reverse(["foo", "bar", "baz"])

Your Solution

Ruby 1.9.3

Back to Problems