From: Dave Thomas Date: 2002-01-12T00:39:45+09:00 Subject: Re: "each" in iterator: confusion "Albert L. Wagner" writes: > I do not understand why this code runs forever. Is it because > the yield is taken to be a second yield in the super class > "each"? Is there a way to do such nested iterators? > > class MyHash < Hash > def each(&block) > super.each do | k, v | > v2 = v * 2 > yield( k, v2) > end > end > end 'super' is not a pointer to the superclass's vtable, but the name of the corresponding method in the superclass. Try def each(&block) super do | k, v | v2 = v * 2 yield( k, v2) end end Cheers Dave