From: Jos Backus Date: 2004-12-02T13:00:41+09:00 Subject: Accessing class constants from within a module? Any idea how I can access a class constant from within a module when that module is include'd in the class? I.o.w. how do I make this work? lizzy:~% cat m module Debug def debug(level, msg) puts msg unless level > DEBUG # XXX DEBUG is wrong! end end class C1 include Debug DEBUG = 1 def foo debug(1, "this is foo") end end class C2 include Debug DEBUG = 2 def bar debug(1, "this is bar") end end C1.new.foo C2.new.bar lizzy:~% ruby m m:3:in `debug': uninitialized constant Debug::DEBUG (NameError) from m:11:in `foo' from m:23 lizzy:~% -- Jos Backus _/ _/_/_/ Sunnyvale, CA _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ jos at catnook.com _/_/ _/_/_/ require 'std/disclaimer'