From: Robert Klemme Date: 2004-06-09T16:38:42+09:00 Subject: Re: question about private method "Robert Klemme" schrieb im Newsbeitrag news:2insr4Fo72u5U1@uni-berlin.de... > > "wang" schrieb im Newsbeitrag > news:dc1b9b9.0406081833.6228ed2e@posting.google.com... > > 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? > > I think, this way enforcing the privacy is made easier (for the > implementor of the runtime). > > Different question: Why would you need to call it like this? > > Regards > > robert > > > > > 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) > Btw: interestingly enough you can do this: >> class Foo >> private >> def test; p "ja"; end >> end => nil >> Foo.new.instance_eval { test } "ja" => nil Regards robert