From: Mark Slagell Date: 2001-08-16T00:15:23+09:00 Subject: [ruby-talk:19788] 2 iterator questions I'm looking at some code in the FAQ (section 5) illustrating the relationship between blocks and proc objects. Two questions come to mind: ------------------------------------- 1. "An iterator is a method which accepts a block or a Proc object." How to accept a proc object? I can't come up with working syntax. This chokes, anyway: pr = proc {|x| x+1} [1,2,3].each pr Since the error indicates that pr is being treated as a paramater, I tried this [1,2,3].each() pr and got a parse error. On the other hand there's no problem sending a proc object through the regular argument list: def iter(aproc) aproc.call 17 end iter pr #-> 18 Is that what is meant by saying iterators can accept proc objects? ------------------------------------- 2. The conversion of a block to a proc inside an iterator(sec. 5.3) is interesting... I'm curious what use it might have though. Any thoughts? Thanks Mark