ruby 方法重载
class MyClass def sayHello return "hello from MyClass" end def sayGoodbye return "Goodbye from MyClass" end end class MyOtherClass < MyClass def sayHello return "Hello from MyOtherClass" end def sayGoodbye return super << "and also from MyOtherClass" end def to_s return "I am an instance of the #{self.class} class" end end
可以作为ruby语言的一大特性
posted on 2013-07-30 15:53 Ijavascript 阅读(452) 评论(0) 编辑 收藏 举报