From: Phrogz Date: 2007-02-09T08:00:11+09:00 Subject: Re: How to "pass" the current binding's block to some other method? On Feb 8, 3:52 pm, "Lyle Johnson" wrote: > Suppose I have a method that will yield to a block if one is given: > > def try(x, y, z) > # ... do some other stuff first ... > yield self if block_given? > end > > Now suppose that I create an alias to this method, for the purpose of > overriding how it's called, e.g. > > alias old_try try > def try(hash) > old_try(hash[:x], hash[:y], hash[:z]) > end > > If someone calls this new and improved version of try() and provides a > block, is there any way for me to somehow pass that block down into > old_try() without actually modifying the method signature? Do you feel that this: def try( hash, &block ) old_try( hash[:x],hash[:y],hash[:z],&block ) end is somehow changing its signature? (You can still choose to pass a block or not.)