From: Sebastian Biallas Date: 2005-06-19T05:05:44+09:00 Subject: Re: Newbe questions... Chuck Brotman wrote: > In Ruby Is there a prefered (or otherwise elegant) way to do an inner & > outer loop with two variables? Well, just nest a second loop into the outer loop... > > eg in psedocode: > > for i=1 to 3 > {for j = 4 to 6 > print i,j, i*j,\nl} > > [..] > Also,how would you generate the same output using the each iterator? (1..3).each do |i| (4..6).each do |j| printf "%d, %d, %d\n", i, j, i*j end end > > > Thanks, > Chuck Sebastian