From: Stefan Rusterholz Date: 2012-05-13T06:12:20+09:00 Subject: Re: Why do you think of NilClass#to_proc? --Apple-Mail=_3D248548-2CDC-4CE5-B3A0-636BC77003C4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Am 12.05.2012 um 16:46 schrieb Intransition: > On Friday, May 11, 2012 4:42:52 PM UTC-4, Jan E. wrote: >=20 > The second solution seems more intuitive to me, since it's a kind of=20= > "empty proc": all parameters are discarded and the proc returns nil.=20= >=20 > That's what I thought too, but then I never came across an actual use = for that definition. You need it if you want to explicitly not pass a block to super. Even = super() will pass on a block. Only super(&nil) doesn't. > But like Bartosz already said: What's the use case for this feature?=20= >=20 > 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: >=20 > def initialize(&block) > @block =3D block.to_proc > end=20 >=20 > But I suppose that's the crux of the issue with this: which default = proc is the right one for a given use case? IMO, don't mess with NilClass#to_proc. There's no need and you break = things if you do. Therefore it's a bad idea IMO. regards Stefan, aka apeiros= --Apple-Mail=_3D248548-2CDC-4CE5-B3A0-636BC77003C4 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii 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=20
"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.

You need it if you = want to explicitly not pass a block to super. Even super() will pass on = a block. Only super(&nil) doesn't.

 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 =3D = 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?

IMO, don't = mess with NilClass#to_proc. There's no need and you break things if you = do. Therefore it's a bad idea = IMO.

regards
Stefan, aka = apeiros
= --Apple-Mail=_3D248548-2CDC-4CE5-B3A0-636BC77003C4--