From: Rick DeNatale Date: 2008-01-08T22:24:35+09:00 Subject: Re: proc to block On Jan 7, 2008 11:35 PM, Gary Wright wrote: > > On Jan 7, 2008, at 11:06 PM, L A wrote: > > > Hello all, > > > > Is there a way to turn a Proc into a block for the purposes of > > methods that yield to blocks? It's not a necessity as I can always > > wrap the Proc in a block, I'm just curious. > > Just prefix the object you want to be passed as a block with '&' in > the argument list. > > p = proc { |x| x > 10 } > > [1,5,10,20, 30].select &p Except that this isn't part of the standard ruby library for 1.8. It relies on having a Symbol#to_proc method It is a common extension, for example Rails includes it. It IS part of Ruby 1.9 though. I'd suggest googling for "ruby to_proc" -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/