...my 0.05$ Blocks cannot be instantiated and &b does not create the block you want. In the expression 'thing(x) &b' '&b' is never evaluated. If it would be evaluated, you'd get a 'parse error'. But 'thing(x)' definitely goes into a recursion! Clemens > -----Original Message----- > From: David Alan Black [mailto:dblack / candle.superlink.net] > Sent: Sonntag, 4. November 2001 21:12 > To: ruby-talk / ruby-lang.org > Subject: [ruby-talk:24344] Re: block/yield puzzle > > Hello -- On Mon, 5 Nov 2001, Erik [ISO-8859-1] B=E5gfors wrote: > On Sun, 2001-11-04 at 20:36, David Alan Black wrote: > > > def thing(x, b = proc { puts "default" } ) > > if block_given? > > yield > > else > > thing(x) &b > > end > > end > > > > thing(1) { puts "associated block" } # => "associated block" > > thing(1) # infinite loop > > Is there anything wrong with this solution?? > def thing(x, b = proc { puts "default" } ) > if block_given? > yield > else > thing(x, &b) > end > end > > thing(1) { puts "associated block" } # => "associated block" > thing(1) # => "default" > > Works for me. Nothing wrong with doing that; I just don't see why thing(x) &b doesn't have the same effect. David --= David Alan Black home: dblack / candle.superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav