From: "Jan E." Date: 2012-05-12T16:42:47+09:00 Subject: Re: Why do you think of NilClass#to_proc? Andrew Grimm wrote in post #1060484: > I had a look at nil last year > http://stackoverflow.com/questions/7410748/how-does-foonil-behave-differently-than-foonot-a-proc > > [1, 2, 3].each(&nil) > doesn't cause any errors, it just returns an enumerator. > > [...] > > I'd try to avoid monkeypatching NilClass if possible. > This isn't a problem with nil.to_proc. You just have to know that nil is treated specially in the "&" syntax for method calls (it's equivalent to calling the method without a block, the to_proc method is *not* called). Which makes a lot of sense, by the way. Especially when passing around blocks. -- Posted via http://www.ruby-forum.com/.