From: "David A. Black" Date: 2009-07-06T07:43:40+09:00 Subject: Re: to_proc and Proc/block conversion with & Hi -- On Mon, 6 Jul 2009, Russ McBride wrote: > Thanks. Interesting discussion. > >> given &expr, if expr is a Proc object, use it as >> the block; if not, call to_proc on it. > ... and then use the resulting proc as a block. > > Maybe the best way to think of & is a a proc/block converter, which, > if called on something that is neither looks first for a to_proc method > before performing its conversion. I'm still not sure whether the lack of calling to_proc on the object if it's already a Proc is just an optimization. I suppose I like the uniformity of &obj always meaning: call obj.to_proc, but if the interpreter is optimizing that away I guess I shouldn't cling to it :-) David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) Training! Intro to Ruby, with Black & Kastner, September 14-17 (More info: http://rubyurl.com/vmzN)