Results 1 to 4 of 4

Thread: How to check if class instance variable was actually initialized?

  1. #1

    How to check if class instance variable was actually initialized?

    How can I do that? Do I check for nil equality or something? I need that for destructor in one of my classes - some of class variables may or may not be created when class is destroyed (they're created as necessary) and I need safe way to tell if they were created or not and if they were, destroy them.

  2. #2
    Assign nil to them in class constructor and check for nil (or use Assigned()) in destructor.

  3. #3
    Quote Originally Posted by Darkhog View Post
    How can I do that? Do I check for nil equality or something? I need that for destructor in one of my classes - some of class variables may or may not be created when class is destroyed (they're created as necessary) and I need safe way to tell if they were created or not and if they were, destroy them.
    That is why SomeClass.Free; is there. When you call SomeClass.Free it automatically checks to see if the calss was created and Destroys it if it Was.

  4. #4
    Junior Member Delphius's Avatar
    Join Date
    Jul 2013
    Location
    Salta, Argentina
    Posts
    9
    It is worthwhile to also consider the fact that something is free, and another thing is set to nil.
    Hence, there is also the procedure FreeAndNil.

    Sorry for my poor english.

    Regards,

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •