You could also write (more generally): puts "aaa".send(:gsub, /./, &prc) -- Markus On Sun, 2004-09-26 at 22:47, Mehr, Assaph (Assaph) wrote: > Hi Guys, > > I started to write this email as a question, but figured the answer in > the middle... :-) > So now I want to know if there's any problem with the code below, if > there is any performance hit or if there's a simpler way to turn Procs > back into blocks. > > The question is how do I #send a method to an object with an attached > proc (not block)? The simplest way to reproduce is: > > prc = lambda{ |a| a.upcase } > puts "aaa".send(:gsub, /./) # how do I pass prc as the block to > gsub? > > Solution: > > puts "aaa".send(:gsub, /./) { |x| prc[x] } > > i.e. I have wrapped my Proc object within a block. Some interspersing of > '*' may be required for multiple params, as Markus pointed out in > another thread. > > > Cheers, > Assaph >