From: "Simon Kröger" Date: 2005-09-22T06:19:38+09:00 Subject: Re: Problem with constants David A. Black wrote: > [...] > Actually A is a constant, not a local variable, and method definitions > aren't closures. I'm pretty sure that what's happening is that the > constant references are being resolved at compile-time, so that by the time > Y.a is run, the reference inside X.a has been permanently resolved to > X::A. > > See what happens when you make this change: > > def X.a > const_get("A") > end > > Now the constant is being resolved dynamically, and you'll get 1/2/3 > in the output. erm, yes. true, but i think this makes it entirely weird. so i call Y::a: self is Y, there is an A in Y but the A from X is used, right? if i redefine X.a to def X.a self::A end it's like i would expect it. Ok, as this looks still completely odd to me (whatelse if not self would do as an implicit target?) there has to be a real good reason why it is this way, right? RIGHT? (i don't have to call self.const_get(:A), why do i have to use self::A to get the A from self?) > David /me still puzzled cheers Simon