> It changes 'self' to the receiver, for the duration of the block.
> It only affects the execution context by binding self to the instance
And the value of self affects:
- explicit uses of "self"
- naked message-sends
- instance and class variable access
Anything else?
Hmmm. This is still a mystery:
class Foo
end
Foo.instance_eval do
def foo ; "foo" ; end
end
p Foo.singleton_methods -> ["foo"]
The "def" should have gone into the top-level environment, but it went
into <<Foo instead. So my hat is still out. (But I'm a lot better off
than I was.)
--
Posted via http://www.ruby-forum.com/.