So here's what I'm trying to do in pseudocode:
array = new Array();
thisObj = new objectTypeOne();
thisObj2 = new objectTypeTwo();
array.push(thisObj);
array.push(thisObj2);
for( i=0; i<=array.length, i++)
{
if( array[i] == objectTypeOne() )
{
//do code
}
}
I know I could have two different arrays for each object type but that would ruin a lot of my other code which assumes they're both in the same array. (they are pratically same object with slight but vital differences, I suppose I should really have objectTypeTwo derive from other, but that's irrelevant at the moment).
I believe what you're looking for is:
The operator "is" does runtime type analysis and will return true if the object you are testing (in this example,
array[i]
) is either directly of the type you're comparing to or a subclass (in this example,MyObjectType
). You might also want to investigate using typeof. However, try to avoid having a TON of calls like this or calls using "typeof"... looking up type information at runtime is costly in any language.