I am trying to understand this behavior.
From page 356 of the Pickaxe (2nd ed):
Protected. Can be invoked only by objects of the defining class and its
subclasses.
If I have
class Foo
...
end
f = Foo.new
Is f not an "object of the defining class"? If so, why should an
instance method of Foo not be able to call a protected class method?
I'm not looking for an answer of the form "because in class scope,
self.class.type.object.class # => Object, however in *instance* scope"
etc. Logically, why should it be this way?
In C++ it makes sense that a static class method cannot call an
non-static method, since static methods exist even when there are no
objects of the class in existence. However, they do not limit you on the
reverse and prevent a non-static method from calling a static method.
--
Posted via http://www.ruby-forum.com/.