Peter Vanderhaden wrote:
> Never mind, I figured it out, sorry!
> 

Here are some ways you might not have thought  of:

a)
arr = ["hello", "world", "goodbye", "mars"]

arr.each_with_index do |elmt, i|
  if i == 3
    break
  end

  puts elmt

end

--output:--
hello
world
goodbye


b)
(0..2).each {|i| print i}

--output:--
012


c)
3.times {|i| puts i}

--output:--
0
1
2
-- 
Posted via http://www.ruby-forum.com/.