From: Pit Capitain Date: 2005-09-21T20:49:01+09:00 Subject: Re: Problem with constants Kroeger Simon (ext) schrieb: > I'm puzzled: > ----------------------- > class X > A = 1 > def X.a > A > end > end > > class Y < X > A = 2 > end > > class Z < X > A = 3 > def Z.a > A > end > end > > p X.a #=> 1 > p Y.a #=> 1 > p Z.a #=> 3 > ----------------------- > (ruby 1.8.2 (2004-12-25) [i386-mswin32]) > > Shouldn't this yield at least a warning? > Is this a feature? Yes. Constants are lexically scoped. As I've learned from a recent post here on ruby-talk, you can change your code to def X.a self::A end to get the behavior I suppose you're looking for. Regards, Pit