W
wang
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
#<Test:0x2ac7318>NoMethodError)
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
#<Test:0x2ac7318>NoMethodError)