From: "Adam P. Jenkins" Date: 2006-02-14T05:23:26+09:00 Subject: Re: Private methods - only available to oneself? 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