From: "Thomas B." Date: 2008-09-02T18:50:10+09:00 Subject: Re: Self and Current Class David A. Black wrote: >> In fact, most of the time this is the way to check the current class. > > I don't think so. Most of the time you're likely to be inside a method > definition body, where the singleton class is not relevant unless you > invoke it more or less explicitly. You're right. That was my sort of inaccurate concept. > I think you're over-complicating this by using instance_eval as your > starting point and then describing the behavior of class definitions > as an exception to a rule. Most of the purpose of class definition > blocks is to define instance methods, so it's easier just to look at > it that way directly. If anything, I'd look at instance_eval as having > the exceptional behavior -- but really, there are so few different > permutations that it's probably easiest just to learn them and not > worry about which is the rule and which the exception. Here I can't fully agree, as I showed it in the previous post there are some more cases, not all of which equally obvious. But it's true that you can call a rule and an exception whichever case you want, for me it's more natural to think that I'm inside instance_eval, because then I'm adding methods to an already existing instance, and not to all the instances potentially existing in the future. > The only really weird one is the top level :-) There's no top level in fact. In the top level, you're inside some instance of Object, you're class<