T
Tim Pease
Is this behavior expected?
$ cat t.rb
class C
def meth1() private_method end
def meth2() self.private_method end
def private_method() puts 'you called?' end
private rivate_method
end
c = C.new
c.meth1
c.meth2
$ ruby --version
ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-cygwin]
$ ruby t.rb
you called?
t.rb:3:in `meth2': private method `private_method' called for
#<C:0x442fdd4> (NoMethodError)
from t.rb:10
It seems distinctly strange to me that you cannot call a private
method using the self semantics shown in meth2. Is this the expected
behavior?
Blessings,
TwP
$ cat t.rb
class C
def meth1() private_method end
def meth2() self.private_method end
def private_method() puts 'you called?' end
private rivate_method
end
c = C.new
c.meth1
c.meth2
$ ruby --version
ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-cygwin]
$ ruby t.rb
you called?
t.rb:3:in `meth2': private method `private_method' called for
#<C:0x442fdd4> (NoMethodError)
from t.rb:10
It seems distinctly strange to me that you cannot call a private
method using the self semantics shown in meth2. Is this the expected
behavior?
Blessings,
TwP