Nathan Weston wrote:
> In ruby 1.6.8, overriding class variables cause weird (to me at least)
> results:
> 
> class Foo
>   Const = 0
> 
>   def c
>     Const
>   end
> end
> 
> class Bar < Foo
>   Const = 1
> end
> 
> print Bar.new.c
> 
> will print "0". Apparently, since Bar.c really calls Foo.c, when it
> looks up the class variable Const, it looks it up in Foo.
> However, this seems odd to me -- I expected the above code to print
> "1".
> Is it supposed to work this way (and if so, why?), or have I
> discovered a bug in ruby?

I think this is because constants are scoped statically. One way to get 
around that is to define Foo#c by:

   def c
     self.class::Const
   end

This forces dynamic scope.