Alexandru Popescu wrote:
> At least in Java these modifiers are quite usefull: a protected method
> is one that offers extensibility/polymorphic behavior for hierarchies,
> without exposing it as public API. So the behavior may vary according
> to the implementation, and the exposed API/public methods are a
> completely different thing.

But Java != Ruby. In ruby, even private methods can be called from
instance methods of a subclass.

irb(main):001:0> class A; private; def foo; end; end
=> nil
irb(main):002:0> class B<A; def bar; foo; end; end
=> nil
irb(main):003:0> B.new.foo
NoMethodError: private method `foo' called for #<B:0xb7b36834>
        from (irb):3
irb(main):004:0> B.new.bar
=> nil

Protected is different from what you expect:

class A
  protected
#  private
  def foo
    puts "foo!"
  end

  public
  def call_foo_on_dup
    dup.foo
  end
end

A.new.call_foo_on_dup # ==> foo!

Now try it with private...

-- 
      vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407