From: Kevin Bullock Date: 2004-05-28T14:20:11+09:00 Subject: Re: Calling global method I might expect (did expect, as a matter of fact) to be able to call such a method just by doing the following: def somemodule::somemethod ::test() end That is, prefix the method name by a double colon as you would a constant defined outside of any module [1]. It doesn't work, though. Some mechanism like that would be awfully useful in certain cases (I've personally come across such a case in a real application), and could be implemented much less hackishly than Ruby currently allows. Specifically, what's needed is a way to access the top-level "module" within which methods are defined (or are they defined in Object by default?). Failing that, see previous replies. [1] See "The Ruby Language" chapter in Pickaxe, section named "Scope of Constants and Variables." On May 27, 2004, at 7:24 PM, Sean O'Dell wrote: > On Thursday 27 May 2004 16:37, Sean O'Dell wrote: >> How do you call a global method from a module method where there is >> another >> module method that shares the name of the global method? > > Perhaps that was too cryptic. Here's an example: > > def test > p "in first test" > end > > module somemodule > def somemodule::somemethod > test() > end > > def somemodule::test > p "in somemodule::test" > end > end > > > In somemodule::somemethod, I intended to call the global test method, > but I > ended up calling somemodule::test. > > How do you call the outer global method in a case like this? > > Sean O'Dell > > > > !DSPAM:40b686e1121078289412664! >