From: Josh Cheek Date: 2011-04-17T03:38:57+09:00 Subject: Re: For loops trouble --0016e645fabc8717b704a10d78a4 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Apr 16, 2011 at 1:36 PM, Josh Cheek wrote: > On Sat, Apr 16, 2011 at 1:27 PM, Daniel Johnson wrote: > >> 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. >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> > numbers = *1..10 > max = 6 > > numbers.each do |num| > break unless num < max > puts num > end > I guess, depending on your needs, you might want the index as well, in which case numbers.each do |num| becomes numbers.each_with_index do |num, index| --0016e645fabc8717b704a10d78a4--