L
listrecv
How can I declare a class method protected?
How can I declare a class method protected?
I realized that my question maybe incorrect.
What I'd like is a class method which can be called by instances of
that class, but is not public.
(The goal? A class which can only be instantiated by already existing
instances. The reason? To ensure a tree.)
I want to ensure that all new instances are created by an already
existing instance, and so incorporated into a tree. No dangling
instances.
vp = pres.new_child # Good
vp = Worker.new # BAD!
def new_child
child = Worker.new
child.parent = self
return child
end
I can't figure out how to mark Worker.new so that it can be called by
instances of Worker but not outside clients.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.