Ramses Aldama
Ramses Aldama

Reputation: 335

Iterating over a complex collection in Dart

I would like to be able to iterate over this collection.

import "package:collection/collection.dart";

main() {
  EqualityMap edges = new EqualityMap.from(const ListEquality(), {
    [1, 'a']: [2, 3],
    [2, 'a']: [2],
    [3, 'b']: [4, 3],
    [4, 'c']: [5]
  });
}

I am doing a recursive function so this is not allowed.

edges.keys.forEach((m) { 
// some more code
return something;
});

Is it possible to achieve something similar to this?

for(var edge in edges)

Upvotes: 2

Views: 194

Answers (1)

Seth Ladd
Seth Ladd

Reputation: 120569

Something like this should work:

for (var edgeKey in edges.keys) {
  var edge = edges[edgeKey];
  // do something
}

Upvotes: 2

Related Questions