http://ruby-metaprogramming.rubylearning.com/html/ruby_metaprogramming_2.html http://galeki.is-programmer.com/posts/183.html 1.3.2 send send( ) is an instance method of the Object class. The first argument to send( ) is the message that you're sendi…
module My NA="China" def My.set_name(name) @name=name end def My.get_name return @name end def My.set_age(age) @age=age end end My.set_name("wanwgenfei") p My.get_name p My::NA module Your Na="AC" attr:name def Your.set_name(…
当一个类拥有可以从多个父类继承的特点,类应该显示多重继承. Ruby没有直接支持多继承,但Ruby模块有另一个精彩使用.他们几乎消除多重继承的需要,提供了一个工厂,称为混入. 混合类型给一个精彩的控制方式增加功能类.在代码中混合类,使用它的代码能进行交互. 语法: module A def a1 end def a2 end end modlue B def b1 end def b2 end end class Sample include A include B def s1 end end…