From: Gavin Sinclair Date: 2004-07-15T17:49:42+09:00 Subject: Re: Question about right way to use module Sam wrote (edited): > [I want to write a module, which] won't be used for a mixin, only > for a function container. > > Q1) Which of the following two is the better way for the > purpose: 'module_function' or 'def self.method'? Personally, I find 'module_function' unintuitive, so I stick with 'self'. There's another idiom I sometimes employ: module X def f end extend self end X.f # -> nil, which is better than "error" I don't know the answer to Q2 or Q3, so they're snipped. > Q4) Let's say that I created functions in a deeply nested module, is > there a short-cut to call the function besides 'include module'? That's easy! module M1::M2::M3::M4 # Only works if M1-3 already exist. def self.foo; 5; end end M4 = M1::M2::M3::M4 # Here's your shortcut. M4.foo # -> 5 Cheers, Gavin