Adam, there's two things here:

1) When you're using an object in Ruby, the *only* way to interact
with it is to send messages to it.  This is uniform across the
language and a damned good idea if you ask me.  Mixing methods with
accessing fields is a bad idea in my book.

2) Ruby provides the Java private method access level with protected,
as mentioned earlier in the thread.  Yes, it requires you explicitly
declare member variables as protected, but if you're dead set on
giving objects access to all the instance variables, you can
definitley do that.

On 2/13/06, Adam P. Jenkins <thorin / theshire.com> wrote:
> Phrogz wrote:
>
> > 1) Any time you use #instance_eval, you should say to yourself "Damn,
> > this is a very sharp knife. I'd better be sure not to cut myself!"
> > Especially if you're messing wih the internals of a class you don't
> > know fully how it works.
>
> The other main thing to be concerned about when accessing private
> methods is that their behavior, or even existence, may change in the
> next version of the class.  Furthermore, except for debugging purposes,
> I'd say that if you find yourself needing to access private class
> methods from outside the class, it's because the class in question needs
> a redesign, or has a bug.
>
> That said, I do think that Ruby's decision to make private mean "only
> accessible to oneself" as opposed to "only accessible to class members"
> is debatable.  In fact I don't see the point of it from a practical
> point of view.  It seems to me that the main reasons for making methods
> private is advertise that a) they're implementation details that may
> change without notice in new versions of the class, and b) they may
> require inside knowledge of the class's workings to use correctly.  Both
> of these reasons would be just as well served by allowing other
> instances of the same class to access private members, so I don't see
> the point of the extra restriction.  Anyone?
>
> Adam
>
>


--
-Dan Nugent