Sean O'Halpin wrote: > On 7/1/06, Alex Young <alex / blackkettle.org> wrote: > >> 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 > > Hi, > > I get a "parse error, unexpected tAMPER" with ruby 1.8.4 (2005-12-24) > [i386-mswin32]. > What version are you using? Sorry, it assumes a working Symbol#to_proc that's supported with that syntax... The proc chaining is what's interesting from my point of view. -- Alex