method references are objects instances of Lang.Method. II you hold method references in an array (list of callbacks for example)
you are nor able to remove the corresponding one by calling myFuncArray.remove(method(:myCallback)) because it seems the object-Ids (or toString() values?) are used for comparison, and not their hashCode() values.
here some debug-output:
Array content: (each array-member is a method-reference, first value is its toString() value, the second one its hashCode(value))
06:18:19PM:D:BaseDataField [
(Lang.Method)Obj: 122(362),
(Lang.Method)Obj: 134(362),
(Lang.Method)Obj: 140(362),
(Lang.Method)Obj: 148(362),
(Lang.Method)Obj: 331(217),
]
I have a function which should remove one particular entry from the array, also having a Lang.Method object as input parameter:
06:18:19PM:>>:BaseDataField delCbOnCompute: (Lang.Method)Obj: 332(217)
06:18:19PM:<<:BaseDataField delCbOnCompute: (Lang.Boolean)false
So i wonder how remove() and removeAll() compare two objects. Are there some specific comparison patterns for basic types and/or SDK classes ?
Generally spoken it would be great to be able to pass a compare function as parameter to remove() and removeAll().
For me there is a simple workaround which consist to store the Lang.Method object into a class member and re-using that one for deleting from the array, but the disadventages are that it uses some memory in you class instance, the other one is that then the emulator complains about 'Circular References Detected' .
Anyway, for my particular use case i probably have to develop my solution further as i should be able to distinguish between several instances of the same class, each one having registered the same class method into that array.
I observe this behavior with every SDK version 2.x (havn't tried 1.x)