From: greg Date: 2004-06-09T18:13:41+09:00 Subject: Re: question about private method On Tue, 08 Jun 2004 19:33:12 -0700, wang wrote: > In ruby FAQ : > The visibility keyword private makes a method callable only in a > function form, and so it can only have self as a receiver. > But,why i can't write like below? > > class Test > def func > self.test #use self > end > > private > def test > p "test" > end > end > > t=Test.new > t.func >>in `func': private method `test' called for > #NoMethodError) class Test def func test # DON'T use self end private def test p "test" end end t=Test.new t.func t.test # but you only can call test "from self" $ ruby test.rb "test" test.rb:14: private method `test' called for # (NoMethodError) $ _