Project

General

Profile

Actions

Feature #5007

open

Proc#call_under: Unifying instance_eval and instance_exec

Added by judofyr (Magnus Holm) over 13 years ago. Updated over 6 years ago.

Status:
Assigned
Target version:
-
[ruby-core:37924]

Description

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

Files

proc_call_under.patch (2.06 KB) proc_call_under.patch mame (Yusuke Endoh), 04/17/2012 10:52 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #6298: Proc#+Rejected04/15/2012Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0