On Sun, Mar 13, 2011 at 2:54 PM, Peter Zotov <whitequark / whitequark.org> wr=
ote:
> On Sun, 13 Mar 2011 23:26:01 +0900, Brian Candler wrote:
>>
>> Peter Zotov wrote in post #987115:
>>>
>>> On Sun, 13 Mar 2011 06:01:31 +0900, Sean O'Halpin wrote:
>>>>
>>>> define_method().
>>>>
>>>
>>> =A0But send() still bothers to pass the block around. Consider the
>>> =A0following code:
>>>
>>> =A0---8<---8<---
>>> =A0def my_method
>>> =A0 p block_given?
>>> =A0end
>>>
>>> =A0def my_send # imitating send
>>> =A0 my_method
>>> =A0end
>>>
>>> =A0my_send # =3D> false
>>> =A0---8<---8<---
>>
>> But compare with this:
>>
>> def my_method
>> =A0p block_given?
>> end
>>
>> def my_send(&blk) # imitating send
>> =A0my_method(&blk)
>> end
>>
>> my_send # =3D> false
>> my_send { :wibble } # =3D> true
>
> That's the whole point of my demonstration. (Maybe I was too concise.)

You were so concise you left out the thing you were trying to demonstrate:

def my_send
  p block_given?
end

my_send { p 42 } #=3D> true

> Any send-like method should to a trick like that to get the block-passing
> behavior. It is not implicit.

It /is/ implicit and is true for any method call. That's how you can do thi=
s:

def my_yield
  yield
end

my_yield { p 42 } #=3D> 42

You specify the &block parameter when you want to do something with the blo=
ck.

Regards,
Sean