摘要: 今天,下面这段程序让我纠结了很久,Ruby中private的概念真的很奇怪。。。 class Test private def test_print puts 'test' endendclass Test2 < Test def test_print2 # self.test_print #=> 这里加上self就不能调用,private method `test_print' called for # (NoMethodError) test_print #=> 不加self就能调用 endendTest2.new.test_print2 为什么不 阅读全文
posted @ 2012-11-08 23:41 BetaRabbit 阅读(256) 评论(0) 推荐(0) 编辑