From: Trans Date: 2007-12-17T21:52:21+09:00 Subject: Re: Is there any way to pass further the "hidden" block? On Dec 17, 3:11 am, "Chiyuan Zhang" wrote: > Like this: > > def foo > yield > end > > def bar(&brk) > foo(&brk) > end > > bar { puts "foo" } > > What I want to know is: is there any way to define `bar' like this: > > def bar > foo > end > > so that foo will get the block passed to bar? I want to know this > because I learn fromhttp://www.pluralsight.com/blogs/dbox/archive/2006/05/09/23068.aspx > that the implicit block is much faster than explicitly passing it > as &brk . I know one solution is > > def bar > foo { yield } > end > > but that create another block, not the original one. Do you mean, is there a keyword #block to go along with #block_given? and #yield? As far as I know, there is no way to pass the block except via an explicit reference. But I think explicit may be the future. I'm pretty sure I've heard some chatter about getting rid of #block_given? Technically I would think it possible to all but eliminate the speed difference between explicit and implicit --3x seems very high. T.