[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Changing the binding of a Proc object

Anselm

6/2/2006 9:33:00 AM

Hello,

Is it possible to change the binding of a Proc object ?

Thanks,
Anselm

2 Answers

Robert Klemme

6/2/2006 10:49:00 AM

0

Anselm wrote:
> Hello,
>
> Is it possible to change the binding of a Proc object ?

You can only change the binding of "self":

>> self
=> main
>> pr = lambda { self }
=> #<Proc:0x003ef918@(irb):2>
>> pr[]
=> main
>> obj = Object.new
=> #<Object:0x3e98a0>
>> obj.instance_eval &pr
=> #<Object:0x3e98a0>

Kind regards

robert

Anselm

6/2/2006 12:22:00 PM

0

Exactly what I needed, thank you. I had looked at the documentation,
but somehow missed instance_eval.

Ansel;