From: Hal Fulton Date: 2006-10-27T09:04:29+09:00 Subject: Re: Pass block instead of here document? Luc Juggery wrote: > Hello All, > > Sorry but I do not really understand the way instance_eval is working > in this sample: > > def tell( obj, &to_do ) > obj.instance_eval( &to_do ) > end > > I'am new to Ruby and Metaprogramming and this method is still obscure to > me. > Can someone help ? > Thanks a lot, Look at it this way: The items inside the block are evaluated in the context of obj, rather than that of the tell method. For example: def tell( obj, &to_do ) p self obj.instance_eval( &to_do ) end If the to_do block were to print self, it would be the same as obj (and *different* from what was printed before the instance_eval). HTH, Hal