In C#, you could do something like this:
public IEnumerable GetItems() { for (int i=0; i<10000000; i++) { yield return i;
It's supported by Enumerator since Ruby 1.9 (and back-ported to 1.8.7). See Generator: Ruby.
Cliche example:
fib = Enumerator.new do |y| y.yield i = 0 y.yield j = 1 while true k = i + j y.yield k i = j j = k end end 100.times { puts fib.next() }