From: James Coglan Date: 2008-11-27T01:57:54+09:00 Subject: Re: How to get a reference to a block (when no explicit block parameter is used?) ------=_Part_13588_9024572.1227718960018 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2008/11/26 Jan Friedrich > Kenneth McDonald wrote: > > > In a function, I can find out if a block was given using block_given?, > > but there's no way I can find to get hold of that block if it's there-- > > I can only yield to it, so far as I can tell. I know there has to be a > > method somewhere to do this, could some kind soul enlighten me? > > > > Many thanks, > > Ken > > def my_meth param, &block > p block > end The way I understood the question was as follows: def my_method(arg) if block_given? yield(arg) end end How to get a reference to the given block in this situation? This is especially true if you use define_method, which cannot specify a block param (at least not in 1.8). Any suggestions? ------=_Part_13588_9024572.1227718960018--