> Yeah, I would not do this. If you want to keep track of them, then
> explicitly add them to a collection.
>
> foo = Foo.new
> foos << foo
>
> Now, when foos gets garbage collected, your instances get garbage
> collected
> (As opposed to the example above, where the class is always referenced
> by
> the constant, and always references the collection containing the
> instances, these instances are essentially permanent).
>
>
> Furthermore, it allows the user to decide how to use the code. Do they
> want
> to keep it in a collection? Then they can put it in a collection. Do
> they
> want to just have one of these instances for a bit and then throw it
> away?
> They can do that, too.

 Woah, I had never thought this way...
 I see what you say kind of dangerous...meaby I have to take a closer
look.
 Also the software that I'm developing is not for programmers or
developers or enginners, just for final users. It will have a GUI, and
it will save big amounts of information trough time and that information
need to be showed to the users almost all the time, so in many ways
there's no option for save or not save some information, the software
just save it and need to keep it. This is a topic very interesting for
me, because I'm desingning the classes now, and soon will be programming
so I'm trying to discover which is the best strategy for keep track of
this objects, and wich is the easiest way to keep them alive once the
software is closed(once I know the first I'll know how to serialize it),
then I'll have to restore all the information back when the program
start again.

>foo_collection = []
>
>foo_collection << Foo.new('nickname')
>
>foo_collection.each do |x|
>  puts x.nickname
>end

 I see Henry Maddocks advice a little tangled. I can't visualize order
in my source code if I take the way he advice, meaby I'm wrong...don't
know.

 Thanks for be helping me.

-- 
Posted via http://www.ruby-forum.com/.