From: Carmine Moleti Date: 2005-11-15T22:22:16+09:00 Subject: module_function question Hi to everyone, let's say I've the following astonishing module: ------------------------------------------------------ module Mod # contained in the file "mymodule.rb" CONST = 1974 def initialize() @initialized_value=892 end def metodo1() puts "this is metodo1" end class MyModClass attr_reader :mymodclass_value def initialize() @mymodclass_value = 2005 end end module_function :metodo1 end ------------------------------------------------------ is it correct that "module_function :metodo1" should allow me to access to "metodo1" the following ways: ------------------------------------------------------ require 'mymodule' Mod.metodo1() # This is Ok, and works as expected class MyClass include Mod attr_reader :myclass_value attr_reader :initialized_value def initialize() super() @myclass_value = Mod::CONST end end temp = MyClass.new() temp.metodo1() # without the module_function, this works! ------------------------------------------------------ Why the line "temp.metodo1()" gives the error: "Private method 'metodo1' called for..." ? The Pickaxe book states that using "Module#module_function" actually makes a copy of the methods and not an alias. Thanks again for your help. Regards, Carmine