To be or not to be.That is a question!

---源于莎士比亚的《哈姆雷特》

导航

ruby Mixin用法

module My
    NA="China"
    attr:name
    attr:age

    def set_name(name)
        @name=name
    end
    def get_name
        return @name
    end
    def set_age(age)
        @age=age
    end
end

class Test
    include My
end

t=Test.new
t.set_name("history")
p t.get_name

 

posted on 2013-07-03 14:02  Ijavascript  阅读(182)  评论(0编辑  收藏  举报