Why does Ruby have both private and protected methods?
protected methods can be called by any instance of the defining class or its subclasses. private methods can be called only from within the calling object. You cannot access another instance’s private methods directly. Here is a quick practical example: def compare_to(x) self.some_method <=> x.some_method end some_method cannot be private here. It must be protected … Read more