realbasic-nug
[Top] [All Lists]

Re: On accessing elements of an array of class instances

To: realbasic-nug at lists dot realsoftware dot com
Subject: Re: On accessing elements of an array of class instances
From: Hector Schisa <joeschisa at mac dot com>
Date: Fri, 29 Feb 2008 10:04:51 -0500
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
>  -- but suppose the array DOES change?  Suppose we were currently  
> accessing the fifth object in the array, and somebody goes and  
> deletes item 2.  Now, which is the correct behavior: continue to  
> access the same object (which is nowfourth in the array), or  
> continue to access the fifth element (which is a different object,  
> as well as a cheesy movie)?

I have spent enough time with "bookkeeping", when using the chosen  
array member's index as reference;  changing the numbers for all  
index references, where ever they are used, when array members are  
removed.   Anyway, the matter seems to boil down, as I think you've  
indicated:  if one wants to hold on to the specific object, use the  
pointer to the array member; if one wants to hold on to the specific  
ordinal member of the array, use the index.  Both ways require some  
error checking (if nil, for the pointer if it's array member is  
deleted; if above the upper bound of the array, if ordinal index is  
used). 
  
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>