From: William Morgan Date: 2005-03-11T21:45:44+09:00 Subject: Re: Is iterating in lock-step possible? Excerpts from Roshan James's mail of 11 Mar 2005 (EST): > On a related note, I had asked this question about C# and it looks like > C# can do both of these cleanly - > foreach( t in foo()) > { > foreach( t in bar()) > { > //nested > } > } I think you might be overlooking the obvious, which is that you can take this approach in Ruby. You're writing the objects that do the computations, right? Simply give them #next? and #next methods and use a while loop. That's what you'd be doing in these other languages. The prevalence of internal iterators in Ruby's API is simply a reflection of the fact that they're so nice to use. It's not the only way to iterate. -- William