这个 python 字典在 Dart 中的等价物是什么?

Ram*_*ama 11 dart

这个 python 字典在 Dart 中的等价物是什么?

edges = {(1, 'a') : 2,
         (2, 'a') : 2,
         (2, '1') : 3,
         (3, '1') : 3}
Run Code Online (Sandbox Code Playgroud)

mat*_*rey 6

您可以使用package:collection'sEqualityMap来定义使用ListEquality. 例如,你可以这样做:

var map = new EqualityMap.from(const ListEquality(), {
  [1, 'a']: 2,
  [2, 'a']: 2,
});

assert(map[[1, 'a']] == map[[1, 'a']])
Run Code Online (Sandbox Code Playgroud)

不过,这将是 Map 的更重的实现。