hello, could anyone explain why sometimes a module is
referenced with “::” before its name? like in
::C
is it equivalent to the regular form “A::C”?
thanks
hello, could anyone explain why sometimes a module is
referenced with “::” before its name? like in
::C
is it equivalent to the regular form “A::C”?
thanks
It’s simply saying “do the lookup starting at the global scope and work
down” instead of “go up the scope hierarchy until you find what I’m
looking
for”.
Useful in the case where you might have similarly named classes in
differing
scopes and need to specify exactly which class you want.
Jason
thanks Jason, very clear explanation.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs