From: Gennady Bystritsky Date: 2006-10-03T01:35:48+09:00 Subject: instance_eva()l-ing a proc with parameters Dear friends, I need to evaluate a proc within an instance context and would like to pass it a parameter. The only straight forward way I found is to use instance_eval(), however it does not allow to pass parameters to a proc, only the instance itself is passed as a single parameter: [rh-30-x86.irvspxl08:1004]gbystrit> irb irb(main):001:0> [ VERSION, PLATFORM ] => ["1.8.4", "i686-linux"] irb(main):002:0> block = proc { |*_args| puts _args.inspect } => # irb(main):003:0> class A; end => nil irb(main):004:0> a = A.new => # irb(main):005:0> a.instance_eval &block [#] => nil irb(main):006:0> a.instance_eval 1, 2, &block # Hypothetical ArgumentError: wrong number of arguments (2 for 0) from (irb):6:in `instance_eval' from (irb):6 from :0 Is there any easy way to do what I want? I also found that I can use define_method() to turn a proc into an instance method and then call it with parameters, however it involves a lot of hassle (for one, define_method() is private). Any thoughts? Thank you, Gennady Bystritsky.