C
Chris Roos
I'm no doubt missing something obvious but I found this a little
confusing. I would have expected the constant lookup to start in Bar
and therefore succeed. Instead, it appears to start in Base where Foo
is not defined.
class Base
def foo
p Foo
end
end
class Bar < Base
class Foo
end
end
Bar.new.foo
# ~> -:3:in `foo': uninitialized constant Base::Foo (NameError)
# ~> from -:12
Can anyone explain what is happening please?
Cheers,
Chris
confusing. I would have expected the constant lookup to start in Bar
and therefore succeed. Instead, it appears to start in Base where Foo
is not defined.
class Base
def foo
p Foo
end
end
class Bar < Base
class Foo
end
end
Bar.new.foo
# ~> -:3:in `foo': uninitialized constant Base::Foo (NameError)
# ~> from -:12
Can anyone explain what is happening please?
Cheers,
Chris