Daniel Johnson wrote in post #993238:
> I am trying to translate a program I have in Java into ruby and having
> trouble translating this for loop
>    for(int i = 0; a[i] < x;i++)
> I tried this
>    for i in a[i]...x
> but it produce some errors. Any help will be appreciated. Thank you.

Ruby has a for-in loop:

a = [2, 4, 1, 9, 6]
x = 7

for num in a
  break if num > x
  puts num
end

But a for-in loop calls each(), so ruby programmers just use each() 
directly:

a.each do |num|
  break if num > x
  puts num
end

-- 
Posted via http://www.ruby-forum.com/.