A
Adam Gardner
I've come across an odd issue when using a constant that is defined
within more than one module namespace. I've searched this
forum/ml/newsgroup for some answers, but I didn't come across anything
that quite addressed the situation I'm seeing.
Can anyone explain why this occurs? Is it supposed to? It doesn't make a
ton of sense to me.
Z::A
It seems to me, though obviously I'm wrong, that the bare constant 'A'
should evaluate to exactly the same thing as self.const_get("A").
In the mean time, I'll just rename my constants to non-conflicting
names, but... why is this working this way in the first place?
within more than one module namespace. I've searched this
forum/ml/newsgroup for some answers, but I didn't come across anything
that quite addressed the situation I'm seeing.
Can anyone explain why this occurs? Is it supposed to? It doesn't make a
ton of sense to me.
Z::Amodule Z
class A
def initialize
puts "Z::A"
end
end
module Y
module X
class A
def initialize
puts "Z::Y::X::A"
end
end
end
class B
include X
def initialize
puts "Z::Y::B"
@a = A.new
end
end
end
end
Z::A.new
=> # said:Z::Y::X::A.new
Z::Y::X::A
Z::Y::B=> # said:Z::Y::B.new
Z::A
=> Z::Y::X::A=> # said:Z::Y::B.const_get("A")
=> Z::Amodule Z
module Y
class B
const_get("A")
end
end
end => Z::Y::X::A
module Z
module Y
class B
A
end
end
end
It seems to me, though obviously I'm wrong, that the bare constant 'A'
should evaluate to exactly the same thing as self.const_get("A").
In the mean time, I'll just rename my constants to non-conflicting
names, but... why is this working this way in the first place?