Alex Young <alex / blackkettle.org> writes:

> Matthew Harris wrote:
>> I don't know if this was posted previously, but I had the idea of a
>> Array#to_proc, an example would be:
>> [9, 19, 29].map(&[:succ, :to_s, :reverse])
>> => ["01", "02", "03"]
>> I've seen people ask questions such as arr.map(&'meth1.meth2.meth3')
>> but I think using the Array#to_proc solution is cleaner.
>> Would this actually prove useful? It would seem that using the
>> normal
>> block form would be just as much typing, though.
>> 
> I'd rather do this:
>
> class Proc
>   def +(other)
>     proc {|*args|
>       args = [self.call(*args)]
>       other.call(*args)
>     }
>   end
> end
>
> [9, 19, 29].map( &:succ + &:to_s + &:reverse )
> #=> ["01", "02", "03"]
>
> but I'm just weird like that :-)

Lovely.  Too bad we can't overload "." ;-)

> Alex
-- 
Christian Neukirchen  <chneukirchen / gmail.com>  http://chneukirchen.org