Couple of questions about constant lookups

I asked something along these lines recently (subject: “const_defined?
not quite in sync with const_get ??”). I don’t think this exact case
was addressed in that mail but I apologise if it was…

I’m wondering why the last two lines in the code snippet below result
in different output.

– code –

module Foo; end
class Bar; end

p Foo::Array #=> NameError: uninitialized constant Foo::Array
p Bar::Array #=> warning: toplevel constant Array referenced by
Bar::Array

– /code –

Cheers,

Chris

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs