From: "Berger, Daniel" Date: 2006-04-20T01:35:19+09:00 Subject: Re: Symbol#to_proc is just so beautiful > -----Original Message----- > From: Daniel Schierbeck [mailto:daniel.schierbeck@gmail.com] > Sent: Wednesday, April 19, 2006 10:27 AM > To: ruby-talk ML > Subject: Symbol#to_proc is just so beautiful > > > When is this ever getting into Ruby Core? > > class Symbol > def to_proc > proc{|obj| obj.send(self) } > end > end > > Consider this: > > class Numeric > def positive? > self > 0 > end > end > > [1, 2, 3].all? &:positive? => true > [-1, 2, 3].all? &:positive? => false > > It's just so damn beautiful! There must be a way to ditch that '&' somehow. I'd prefer this: [1,2,3].all?(:positive?) Dan