From: Alex Young Date: 2006-07-02T01:58:15+09:00 Subject: Re: Arrray#to_proc 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 :-) Is this useful for anything? It looks like it should be, but I can't think of what... -- Alex