From: Michael Hollins Date: 2007-06-29T22:05:10+09:00 Subject: Re: Accessing functions in a module without 'include' Ronald Fischer wrote: > Usually I work with modules like this: > > # Defining a module in one file > module M > def f(x) > .... > end > end > > # Using the module in another file > require 'M' > include M > f(45) > > Sometimes I would find it more convenient to *not* inject > the module's namespace into the user's namespace, i.e. to > do it without the include statement. I thought it would > be easy to qualify the foreign function with the module > name: > > # Using the module in another file > # (this does not work) > require 'M' > M::f(45) # Error: undefined method 'f' > > Maybe I'm thinking to Perlish here. Can it be done what I want > to achieve, and how? Not sure if it's what you want, but if you define M as follows it works: module M def self.f(x) .... end end cheers, mick