Project

General

Profile

Feature #5007

Updated by nobu (Nobuyoshi Nakada) almost 2 years ago

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

 `Proc#call_under(self, 

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

 ```ruby 
 &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 
 ```

Back