On Mon, Apr 19, 2004 at 07:59:07PM +0900, Simon Strandgaard wrote: > On Mon, 19 Apr 2004 20:42:58 +0900, ts wrote: > >>>>> "S" == Simon Strandgaard <neoneye / adslhome.dk> writes: > > > > S> My code can take an optional block. Your above code > > S> must be supplied a block. > > > > What do you call an optional block ? > > I was hoping that I had made a method which could take > an optional block.. ala > > def m > if block_given? > yield > end > end > > I wanted to convert that yield into a block, which I could > pass further around (as a block). > .... > Any idea how to do this? > > -- > Simon Strandgaard Ok, so an &-parameter accepts an optional block, but aside from that, doesn't this convert the block to a proc? I'm not quite sure because of the other thread going on shows that scoping rules about proces and lambdas are convoluted, and I don't quite understand how they work. proc do yield end It seems that it works, look: def mypr; if block_given?; then proc do yield; end; else proc do puts "default"; end; end; end; p= mypr do puts "hi"; end; 5.times(&p); q= mypr; 5.times(&q); ambrus