From: "Mark J. Reed" Date: 2003-07-30T11:09:47+09:00 Subject: Re: Passing a method block to a parent class On Sun, Jul 27, 2003 at 07:58:50AM -0700, Eric Anderson wrote: > If I have > > **** CODE **** > > class A > def method1( argument ) > yield( argument ) > end > end > > class B < A > def method1( argument ) > puts argument > super.method1( argument ) > end > end > > obj = B.new > obj.method1( 'foo' ) { |arg| puts arg + 'bar' } > > **** CODE **** > > How do I change this to allow class A to get the block. Bascially I To pass blocks around you have to use proc arguments. If you declare a method thus: def method2 (argument, &block) end Then any block associated with a call to the method will be turned into a Proc object and assigned to the &-marked parameter (which must be last in the list). Like *, this works both ways; if you pass a Proc as the last parameter of a method call and put a & in front of it, the called method sees it as a block. So this should do what you want: class B < A def method1( argument, &block ) puts argument super.method1( argument, &block ) end end -Mark