2

I have come across this when using as3hx to port my AS3 code to Haxe:

delete classMemberDictionary[key]

as3hx can't translate this to Haxe, you have to do it manually. I've read the as3hx README and it says

  1. if it is a local variable, replace delete varname with varname = null
  2. if it is a class member variable, remove the delete entirely

Since it is a dictionary item it doesn't seem right to just remove the line, as the README says. Should I set it to null?

frostbyte
  • 103
  • 2
  • 8
  • What are your key types? You may want to translate `flash.utils.Distionary` to a `haxe.ds.ObjectMap`, if your keys are objects / instances. If the keys are `String`, use `haxe.ds.StringMap`. And either way, as @gama11 says, use `remove()` for deleting. – Jeff Ward Oct 09 '18 at 14:39

1 Answers1

5

Are you using Map or openfl.utils.Dictionary? In either case you can use remove():

Setting the value to null isn't quite the same. Although get() would return null in either case, exists() still returns true for entries that weren't explicitly removed.

Gama11
  • 31,714
  • 9
  • 78
  • 100