From: Johan Holmberg Date: 2004-01-16T05:22:47+09:00 Subject: Re: Concatenating variable number of Arrays ? On Fri, 16 Jan 2004, Florian Frank wrote: > On 2004-01-16 00:03:39 +0900, Johan Holmberg wrote: [...] > > > I agree. > > Where can I read about 'to_proc' and how it works ? > > This trick uses the function block_pass in eval.c. If you pass an object > with & operator to a method, a conversion to a Proc object is attempted > in this function, by calling to_proc on this object. Usually there are > only Method and Proc objects in Ruby that implement this method. But you > can also define your own classes with to_proc if you like. Actually it's > an application of duck typing. > Thanks for the explanation. Is this documented somewhere or have you found out by reading the code ? One thing I wonder is if the 'Symbol.to_proc' method you described is too global. What if we would like to define the method in a different way somewhere else ? Or is it poosible to define 'Symbol.to_proc' in a natural way ? And in that case, why isn't it already built into Ruby ? /Johan Holmberg