module BaseFunc Version="0.0.1" def V return Version end def add(a,b) return a+b end def self.showVersion return Version end #将V方法定义为静态方法 module_function:V end puts BaseFunc::Version puts BaseFunc.showVersion puts BaseFunc::showVersion puts BaseFunc.V class BaseClass include BaseFunc end puts BaseClass::Version # puts BaseClass.showVersion # puts BaseClass.V myCls=BaseClass.new puts myCls.add(10,20)
运行结果