Vector or array for deletion?

howdy folks,

so i have gotten to a good point on using arrays with openfl. which is great, but still run into starnge erros, even though some things im sure are ok.
but i done a bit more digging and thought of vectors instead. which from what ive seen would be better to use.
is there anything that can show on how to use them in the way of arrays?
or is it just like using array?

so say with a regular array it would be

var array:Array<String> = ["a", "b", "c", "d"];
var i:Int = array.length;
while(i-- > 0) {
    if(i == 1) {
        array.splice(i, 1);

would this be a bit like using Vector?
just need some clarification on some things or pointers


There are a few functions that one has and the other doesn’t, but in general, coding with vectors is exactly the same as coding with arrays. For instance, you could take the code you posted, replace “Array<String>” with “Vector<String>”, and it would work with no other changes.

If you’re running into “strange errors” using arrays, you’ll probably run into the same errors using vectors, because the two are so similar. The solution is to fix your mistakes, not switch data types.

1 Like

thats fair enough and really good to know.
aye. the same problem is the odd deletion [using hitTestObject]. but need to dig further into :wink:

but thanks for pointing out that vectors and arrays are pretty much just the same :wink: