From: Pit Capitain Date: 2006-08-02T22:59:15+09:00 Subject: Re: I thought this was the one that worked? Chad Perrin schrieb: > In any case, this can happen in Ruby: > > class Foo > def bar > lambda { puts "quux" } > end > end > > foo = Foo.new > bar = foo.bar > > bar.call Chad, I didn't carefully read all of this long thread because I've been offline for a couple of days. You don't have to answer to this mail, if it isn't relevant to you. I had the impression that you think a block can't be called a closure if it doesn't reference any free variables from its context, just as the block in the example above. If I understand you correctly, then the following two blocks should be exactly the same, shouldn't they? blk1 = Foo.new.bar blk2 = Foo.new.bar But they aren't the same, as can be seen from the following code: eval "self", blk1 # => # eval "self", blk2 # => # As you can see, each block remembers at least the value of "self", when it was created. You can get at this value even if the "self" object goes out of scope, as you can see from my code above. There's no explicit reference to the two instances of Foo. From this it follows (at least for me), that each block in Ruby is a closure. Regards, Pit