I'm trying to understand what the following will produce. According to IRHG, this code will return A1.
IRHG says: Constants are search for first outside the class. If not found
outside, then searched inside the class.
But I've got the following message in Ruby 1.8.7
uninitialized constant A3::B3::C3::Const (NameError)
Would you please help me to understand this correctly?
class A1
Const = "A1"
end
class A2 < A1
end
class A3 < A2
#Const = "A3"
class B1
end
class B2 < B1
end
class B3 < B2
class C1
end
class C2 < C1
end
class C3 < C2
p Const
end
end
end
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…