Check wheater an instance of a class is actually there or not

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Check wheater an instance of a class is actually there or not

Hans Gruber
Hi Squeak Community!

as mentioned above im am totally new in Squeak Programming and I found very good tips here already, thanks for that!

Now to my question:

How may I check wheater an instance of a class (in my case MyFileLibrary) has been created and exists at the time I check it.

(MyFileLibrary = nil) is always false.

I need this, because wenn an Instance of MyFileLibrary exists at the checking time, I want to proceed with an other method than I want to proceed with when an instance of MyFileLibrary does not exists.

Can anybody help me?

Regards.
___________________________________________________________
Preisknaller: WEB.DE DSL Flatrate für nur 16,99 Euro/mtl.!
http://produkte.web.de/go/02/

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Check wheater an instance of a class is actually there or not

Randal L. Schwartz
>>>>> "Hans" == Hans Gruber <[hidden email]> writes:

Hans> Now to my question:

Hans> How may I check wheater an instance of a class (in my case MyFileLibrary) has been created and exists at the time I check it.

Hans> (MyFileLibrary = nil) is always false.

Hans> I need this, because wenn an Instance of MyFileLibrary exists at the
Hans> checking time, I want to proceed with an other method than I want to
Hans> proceed with when an instance of MyFileLibrary does not exists.

Sounds like you want the singleton pattern.

The easiest way to do that is to not create instances at all,
and just dump all of your methods class side, and all of your "instance"
variables as "class instance" variables.

Then treat MyFileLibrary as if it is the only instance that ever exists,
and has a global name.

If that's not what you want, explain more.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[hidden email]> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners