Consider the following (correct) Ruby program:
class Outer
Inner = Struct.new(:dummy) do
CONST = \'abce\'
def fun
puts(dummy)
end
end
After a little digging I was able to figure this out. Here's a quote from a similar question:
Constants belong to classes, therefore constant resolution via the :: operator only works with class objects.
In your above example Inner is a constant not a class, so Outer::Inner::CONST won't work. If we redefine Inner as a class we see the expected results.
class Outer
class Inner
CONST = 'abce'
Deeper = Struct.new(:dummy) do
def fun
puts(dummy)
end
end
end
end
obj = Outer::Inner::Deeper.new(15)
obj.fun
puts(Outer::Inner::CONST)