7stud -- wrote in post #991945:
>
> The protected method rule states that you can use a receiver to call the
> method--so long as whatever object is self at that time is also an
> object of the same class as the receiver (or a parent or subclass).

I think we need to scratch '(or parent...' off the list:

class Animal
  def meth(obj)
    obj.bark  #self=anim whose class is Animal,
  end         #and Animal is a parent class of obj=dog
end

class Dog < Animal
  protected
  def bark
    puts 'woof'
  end
end

dog = Dog.new
anim = Animal.new
anim.meth(dog)

--output:--
prog.rb:3:in `meth': protected method `bark' called for #<Dog:0x9f8948c> 
(NoMethodError)
  from prog.rb:22:in `<main>'

-- 
Posted via http://www.ruby-forum.com/.