Project

General

Profile

Actions

Bug #5288

closed

Method#to_proc Procs have "sticky" bindings

Added by ernie (Ernie Miller) over 13 years ago. Updated over 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0]
Backport:
[ruby-core:39315]

Description

Please see the attached sample script (or view the gist at https://gist.github.com/1197634).

It would appear that a Proc object that is obtained via Method#to_proc behaves unlike other Procs when used with instance_exec. I'm not entirely sure that this is a bug so much as a gap in documentation, but I found it interesting, in either case, to note the subtle difference.

The summary:

A Proc object created by Method#to_proc doesn't actually allow instance_exec to modify "self" for the block. Sample output is provided in the comments of the attached script.

Thanks in advance!


Files

method_to_proc.rb (873 Bytes) method_to_proc.rb ernie (Ernie Miller), 09/07/2011 08:51 AM

Updated by nobu (Nobuyoshi Nakada) over 13 years ago

  • Status changed from Open to Rejected

A method is bound to the internal structure of its receiver.
Therefore this is a spec.

Actions

Also available in: Atom PDF

Like0
Like0