Moktah Posted February 7, 2018 Share Posted February 7, 2018 arSomeArray[2][15] == arSubArrayAarSomeArray[2][20] == arSubArrayB <---- trying to delete thisarSomeArray[2][25] == arSubArrayC I want the result to bearSomeArray[2][15] == arSubArrayAarSomeArray[2][25] == arSubArrayC (side note the 15, 20, and 25 are keys to a map array so those keys don't change like a regular array would and I can have the skips in numbers) IF I wanted to delete that entry,should I....let arSomeArray[2][20] := ar_null <--- if I am understanding this right... I am Nulling out the arSubArrayBar_erase arSomeArray[2] 20 <--- now I am erasing the Key or just...ar_erase arSomeArray[2] 20 I've tried both ways and don't get an errorI've done this as wellshort vCountlet vCount := ar_erase arSomeArray[2] 20msgex "vCount = %g", vCount But it returns a 1 either way. I don't want to end up in a situation like thisarSomeArray[2][15] == arSubArrayA(nothing) == arSubArrayB <---- this sub array still exists but it don't have an 'owner?' so to speak and no way to erase it any morearSomeArray[2][25] == arSubArrayC Link to comment Share on other sites More sharing options...
QQuix Posted February 7, 2018 Share Posted February 7, 2018 (if memory serves...) ar_erase arSomeArray[2] 20 <--- now I am erasing the Key Removes the entry (both key and value). As I understand it, this is what you want let arSomeArray[2][20] := ar_null <--- if I am understanding this right... I am Nulling out the arSubArrayB This does not change the array. arSomeArray[2][20] remains in the array, now pointing to a null array.If this entry was the last reference to arSubArrayB, it will be destroyed. If not, arSubArrayB will continue to exist and other references to it continue to be valid.This is not necessary if you use ar_erase arSomeArray[2] 20 let vCount := ar_erase arSomeArray[2] 20 ar_erase returns the number of entryes deleted. E.g. ar_erase arSomeArray[2] 16:99 would return 2 after erasing the two elements in that range (15 and 25) Link to comment Share on other sites More sharing options...
Moktah Posted February 7, 2018 Author Share Posted February 7, 2018 Thats what I needed to know.Thanks you thank you Link to comment Share on other sites More sharing options...
Recommended Posts