From: Sam Sungshik Kong Date: 2004-07-15T17:22:22+09:00 Subject: Question about right way to use module Hi, folks! Modules are used for 1. mixins 2. function containers I want to make some utility functions in a module which will be mostly used in irb to test things. The module 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(function container)? (1) module M module_function def f ... end end (2) module M def self.f ... end end If I understand correctly, (1) copies the function and wastes space. Then (2) will serve my purpose better. Am I correct? Q2) In the above, is (1) exactly same as the following? module M def f ... end module_function :f end Q3) If I do (1), how can I end module_function section? One way I can think of is close the module and re-open it. Any other way? module M module_function def f ... end def f2 #->still module_function ... end def f3 #I want to make f3 non-module_function ... end end 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'? M1::M2::M3.f I wish I could make an alias like alias :M :M1::M2::M3 #wrong example M.f I guess I asked too many questions for this late night...:-) Thanks. Sam