From: Dark Ambient Date: 2006-06-29T05:45:48+09:00 Subject: Re: Looping through 2 arrays Okay ..thanks! makes sense. Apologies also for leaving the que_words and s_words in the puts statement. I meant to change them out since unsorted and sorted are easier to understand. Stuart On 6/28/06, Logan Capaldo wrote: > > On Jun 28, 2006, at 4:34 PM, Dark Ambient wrote: > > > I'm trying to loop through 2 arrays, and notice some odd behaviour, > > probably because the syntax is not correct > > > > unsorted.each do |x| > > sorted.each do |y| > > puts 'this is que_words ' + x + '.' > > puts 'this is s_words ' + y + '.' > > end > > end > > > > I added the 'puts' in as I'm trying to build a bigger block of code > > and trying to take it one step at a time with some checking in place. > > unsorted has elements, sorted is empty. > > > > When I run the above, nothing is output. When I comment out the > > sorted loop, unsorted outputs it's elements. Would having an empty > > array effect the output of unsorted or is this just plain wrong ? > > > > Stuart > > > > If sorted is empty it, never enters the sorted.each block, which is > where all the output is. Try this > > unsorted.each do |x| > puts 'this is que_words ' + x + '.' > sorted.each do |y| > puts 'this is s_words ' + y + '.' > end > end > > > >