Issue #5007 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to matz (Yukihiro Matsumoto)


----------------------------------------
Feature #5007: Proc#call_under: Unifying instance_eval and instance_exec
https://bugs.ruby-lang.org/issues/5007#change-25150

Author: judofyr (Magnus Holm)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: 
Target version: 


I'm proposing a method called Proc#call_under (the name could be
discussed) which both unifies instance_eval and instance_exec, and makes
it possible to call a Proc with a block and a scope:

  Proc#call_under(self, *args, &blk):

    proc { self }.call_under(1) # => 1

    proc { |a| self + a }.call_under(1, 2) # => 3

    proc { |&b| self + b.call }.call_under(2) { 2 } # => 4


-- 
http://bugs.ruby-lang.org/