2016年2月2日

ruby self.included用法

摘要: ===Module#included 当一个模块混入到类时,如果该模块的included方法已经定义,那么该方法被调用。该方法的唯一参数就是接受混含的类的名字。 1 module M 2 def self.included(c) 3 puts "I have justbeen mixed into 阅读全文

posted @ 2016-02-02 22:25 tim_sheng 阅读(937) 评论(0) 推荐(1) 编辑

ruby include和exclude区别

摘要: 很久没玩ruby了,今天看源码的时候,看到extend硬是缓不过神了,Google下extend和include的区别,做个记录 在class中include module, 那么module中的方法将成为类的实例方法 在class中extend module, 那么module中的方法将成为类的类 阅读全文

posted @ 2016-02-02 22:19 tim_sheng 阅读(1043) 评论(0) 推荐(0) 编辑

导航