herman_graal / europe.com wrote: > > Hi, > > This may be an indication of bad design but in a current project I have a class (C) with a number of constants (B1, B2, ...) that I wan't to access from another class (A). > > Is there some way to include or extend A with C so that I can write B1 etc directly in A without having to prefix them with C::B1. This isn't quite what you're asking for, because it's static. Adding constants to C later on won't affect A. ------------- class Class def share_constants c for const in c.constants - c.superclass.constants do const_sym = const.intern const_set(const_sym, c.const_get(const_sym)) end end end class C B1 = 1 B2 = 2 end class A share_constants C p B1 p B2 end ------------- What you really need is a hook for constant evaluation. I tried redefining const_get in A, but that's apparently not called by "A::FOO".