From: Kalman Noel Date: 2007-02-12T23:35:09+09:00 Subject: Re: What is Proc#== Sylvain Joyeux: > From the description, > ---------------------------------------------------------------- Proc#== > prc == other_proc => true or false > ------------------------------------------------------------------------ > Return true if prc is the same object as other_proc, or if they > are both procs with the same body. > > I thought that a == b in > ============================================= > def block_to_proc(&prc) > prc > end > def test > block_to_proc do > end > end > > a = test > b = test My guess would be that a and b were created in different contexts, and that this is why they are not equal. The problem about that is that thay aren't really created in different contexts here. They are in this case, however: def test(arg) block_to_proc { arg } end a = test(1) b = test(2) Obviously a and b are not equal here, because a.call and b.call are not equal. Note, also: x = 3 lambda { } == lambda { } # => true lambda { x } == lambda { x } # => false (maybe because x may have changed in between) Still the behavior you described seems like a bug to me, because of lambda { } == lambda { }. But I may not see the existing reason why it isn't. Kalman