February 2, 2004 Intro to Ruby Slide #19
Prev Next

Closures and iterators

Unfortunately, however, procs can't be iterators like regular methods can:
     def make_iterator (x)
       return proc { yield x }
     end

     iter = make_iterator
     iterator.call(42){ |n| puts n } # DOESN'T WORK



Prev Copyright © 2004 Walter C. Mankowski Next