Re: How does the private method work?
I’m not quite sure what you are asking but …
“private” is not a keyword but, instead, a method. So one can dynamically make other methods, uh, private or not.
Two links of interest might be
Tuesday, April 17, 2018, 3:21:32 AM, you wrote:
Thanks Ralph. I understand what “private” as an OOP construct does. But as Christian mentioned, I am looking at how ruby interprets it. For instance, I see ruby also allows this
private :first_method, :second_method
Is the above private and the private I mentioned in my initial question, the same ? If not, how are they not the same ?
On Tue, Apr 17, 2018 at 1:27 PM, Ralph Shnelvar firstname.lastname@example.org wrote:
The idea behind “private” in most/all OOP languages is that you are telling other developers and/or yourself to not use this/these methods in the future as
the interface to the method may change
the side effects may change
When you declare a method, e.g.
def some_method(arg1, arg2, arg3)
you are establishing a “contract” between your object and the outside world.
By declaring the method private you are telling the world “Don’t call this! I may not implement this functionality at all in future versions!”
Tuesday, April 17, 2018, 1:16:08 AM, you wrote:
I just saw one developer do this in his code :
private if some_condition?
I was wondering how the private method works. How does it figure out which methods to mark private ?
It would be nice if someone could explain this or point me to appropriate resources on the web.