From: Intransition Date: 2012-05-12T23:46:13+09:00 Subject: Re: Why do you think of NilClass#to_proc? ------=_Part_70_15212211.1336833969360 Content-Type: multipart/alternative; boundary="----=_Part_71_20419028.1336833969360" ------=_Part_71_20419028.1336833969360 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Friday, May 11, 2012 4:42:52 PM UTC-4, Jan E. wrote: > > > The second solution seems more intuitive to me, since it's a kind of > "empty proc": all parameters are discarded and the proc returns nil. > That's what I thought too, but then I never came across an actual use for that definition. > But like Bartosz already said: What's the use case for this feature? > If you have a method that takes an optional block and no block is given then it can default to the pass-thru proc via convenient: def initialize(&block) @block = block.to_proc end But I suppose that's the crux of the issue with this: which default proc is the right one for a given use case? ------=_Part_71_20419028.1336833969360 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

On Friday, May 11, 2012 4:42:52 PM UTC-4, Jan E. wrote:

The second solution seems more intuitive to me, since it's a kind of
"empty proc": all parameters are discarded and the proc returns nil.

That's what I thought too, but then I never came across an actual use for that definition.
 
But like Bartosz already said: What's the use case for this feature?

If you have a method that takes an optional block and no block is given then it can default to the pass-thru proc via convenient:

    def initialize(&block)
      @block = block.to_proc
    end

But I suppose that's the crux of the issue with this: which default proc is the right one for a given use case?


------=_Part_71_20419028.1336833969360-- ------=_Part_70_15212211.1336833969360--