> Posted by Robert K. (robert_k78) on 2011-04-13 13:45 > The logic is a bit tricky. :-) The Enumerator::Generator is just > something which can enumerate something. There is no infinite loop > until you start iterating that instance via #each or any other method > defined in Enumerable. Actually the loop is "interrupted" every time > "y << num" is invoked. > OK. So I guess this syntax: e = Enumerator.new do |y| (0..9).cycle do |num| y << num end end Is more declarative in that it just declares an enumerator without setting off the infinite loop inside. To execute the loop one needs something like: e.take(15) And then there is no infinite loop either, as the amount of iterations is scoped by the argument to take(). Great examples in your post, I appreciate it! -- Posted via http://www.ruby-forum.com/.