From: Zach Dennis Date: 2005-02-11T08:02:19+09:00 Subject: Re: redefine Kernel method koboi wrote: > It moves in the right direction, yes, thanks. > But still, it doesn't work as I would like. If I want to count, how many > times the method is called, the Proc is evaluated only once, so the count > is always 1. > Example: > @count = 0 > m = proc { @count += 1; 5 } > #... > #call rand several times > p @count -> 1 > I'm going to repost after i figure this one out, the problem with my first post (and i apologize for posting inaccurate code), was that the "#{m.call}" was getting evaluated in the 'module_eval( "..." )' and it wasn't actually getting called when rand got called. Kernel.module_eval( "def rand; #{m.call}; end" ) Will have rand return the value of m.call. It will always return the same thing, because m.call is evaluated in the String, and not when rand is called. m = proc { 50 } def rand; #{m.call}; end is the same as: def rand; 50; end working on a solution, Zach