From: "Iñaki Baz Castillo" Date: 2008-09-10T19:49:25+09:00 Subject: Re: How to change the owner of a method in a block? 2008/9/10, Lex Williams : > Lex Williams wrote: > > one way would be to use instance_eval : > > > > def new(&blk) > > instance_eval &blk > > end > > I meant to write : > > def initialize(&blk) > instance_eval &blk > end Really great :) Let me just a question: how does affect using "instance_eval" in performance? I've done some simple tests: >> Benchmark.realtime { a=123; a2=a*2; a3=a*3 } # => 1.97887420654297e-05 >> Benchmark.realtime { instance_eval 'a=123; a2=a*2; a3=a*3' } # => 4.50611114501953e-05 Well, it seems that using "instance_eval" takes the double of time than running the code directly. Is it significant? Thanks. -- Iñaki Baz Castillo