Reputation: 13
My code:
var dict = new Dictionary();
dict[[1, 2]] = 1;
var dbg = dict[[1, 2]];
trace(dbg);
Output:
undefined
Why?
How can I get
set<pair<int, int> >
from C++?
Upvotes: 0
Views: 531
Reputation: 100545
Note: I would not call [1,2]
"pair of int", it is "array with 2 elements". { item1:1, item2:2 }
would look more like pair to me.
According to documentation Dictionary uses strict equals (===) to compare keys, so passing new array as key every time will not work for indexing (arrays are strictly equal only when it is exactly the same array, not an array with the same content).
Depending on your needs converting key to a string maybe good option:
var keyPair = [1,2];
var key = keyPair[0] + "_" + keyPair[1];
Upvotes: 1