From: noreply@... Date: 2006-02-15T09:44:58+09:00 Subject: [ ruby-Bugs-3565 ] Method object used as Object#instance_eval block doesn't work (as expected) Bugs item #3565, was opened at 2006-02-15 02:32 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=1698&aid=3565&group_id=426 Category: Core Group: None Status: Open Resolution: None Priority: 3 Submitted By: Ozgur Murat Homurlu (omh) Assigned to: Nobody (None) Summary: Method object used as Object#instance_eval block doesn't work (as expected) Initial Comment: I'm pasting an irb session which demonstrates the situation: ------------- irb(main):001:0> class W irb(main):002:1> def foo irb(main):003:2> p self irb(main):004:2> end irb(main):005:1> end => nil irb(main):006:0> class A irb(main):007:1> def bar irb(main):008:2> w = W.new irb(main):009:2> m = w.method(:foo) irb(main):010:2> instance_eval &m irb(main):011:2> end irb(main):012:1> end => nil irb(main):013:0> a = A.new => # irb(main):014:0> a.bar ArgumentError: wrong number of arguments (1 for 0) from (irb):5:in `foo' from (irb):5:in `to_proc' from (irb):10:in `bar' from (irb):14 from :0 irb(main):015:0> # Hmm, there's an extra argument is passed to W#foo, irb(main):016:0* # Let's see what it is: irb(main):017:0* class W irb(main):018:1> def foo(x) irb(main):019:2> p x irb(main):020:2> p self irb(main):021:2> end irb(main):022:1> end => nil irb(main):023:0> a.bar # # => nil --------------- It seems like, unexpectedly introduced argument is the object "a". Also, "a.instance_eval" doesn't work, self is still instance of "W". The ruby version used is: $ ruby --version ruby 1.8.4 (2005-12-24) [i386-linux] ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=1698&aid=3565&group_id=426