# Dictionary

**URL:** https://forum.kirupa.com/t/dictionary/326547
**Category:** Uncategorized
**Created:** [December 22, 2011, 1:58pm UTC](https://forum.kirupa.com/t/dictionary/326547 "2011-12-22T13:58:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![masterLaser](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@masterLaser](https://forum.kirupa.com/u/masterLaser)
#### Post date: [December 22, 2011, 1:58pm UTC](https://forum.kirupa.com/t/dictionary/326547/1 "2011-12-22T13:58:43Z")

</div>

Hi!

If you do:

```auto
var arr:Vector.<int> = new Vector.<int>();
arr.push(1, 2, 3, 4);

for (var i:int = 0; i < arr.length; i++) 
{
    if (i == 2)
    {
        arr.splice(2, 1);
    }
    
    trace(arr*); // 1, 2, 4
}

```

The 3 gets skipped, obviously. I know i can avoid this by going backwards in a loop, but that is not safe if 2 elements gets deleted in the same irreation (spelling?). So, I use a dictionary insted. From what I understand this problem is solved by using a dictionary, if you delete 2 items in a dict in the same irreation the looping will not be effected (the deleted items wont be looped ofc).

However, I got a bug where it seems that by removing items in a dict while looping it, the looping gets messed up and some items in the dict will not be looped at all.

My question: Can I remove items in a dictionary while looping without messing up the loop? I tried to test this and it seems it does not effect the looping, but it seems like the looping is effected in the bug that i have.
