From: Joel VanderWerf Date: 2007-02-09T09:20:33+09:00 Subject: Re: How to "pass" the current binding's block to some other method? Lyle Johnson wrote: > On 2/8/07, Phrogz wrote: > >> Do you feel that this: >> def try( hash, &block ) >> old_try( hash[:x],hash[:y],hash[:z],&block ) >> end >> is somehow changing its signature? > > For the purposes of this discussion, yes. Perhaps a better way to > phrase the question is whether there's any way to do it without > modifying the original source code for try(). > >> (You can still choose to pass a block or not.) > > Yes, I get what you're saying. I'm just hoping to not have to modify > the original source (if possible). Does this help? class Foo def try(x, y, z) # ... do some other stuff first ... yield self if block_given? end alias old_try try def try(hash) old_try(hash[:x], hash[:y], hash[:z]) do yield self if block_given? end end end Foo.new.try({}) do puts "trying" end -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407