Why does my new array already have one member?

I am building an array of objects using this code:

msgbox("Before adding this triple triplesArray in theGraphStore has " + app.theGraphStore.triplesArray.Count.toString + " members")
app.theGraphStore.triplesArray.add(thisTriple)
msgbox("triplesArray in theGraphStore now has " + app.theGraphStore.triplesArray.Count.toString + " members")

When I run the application the first msgbox reports a count of 1 even though I haven’t added anything to this array yet. I don’t seem to be able to inspect this implicit 0th member as it doesn’t have any properties that I can find (nilobjectexceptions happen). The second msgbox reports 2 members and I can inspect array(1) but still not array(0).
I’m probably making some basic silly mistake, but I can’t see it. Can anyone point me to what I may have done wrong here?

Ah, I see what I did. I declared the tripleArray array like this: tripleArray(0). Now sorted.

Yes, the declaration of zero isn’t a size it’s a highest index. So ‘name(-1) as type’ is the empty array.

You can also just declare it without a number to get the empty array.

Var tripleArray() as Something
3 Likes

Thanks for the replies, everyone. The problem is resolved.