toSet method
Move the set's elements that satisfy the predicate to another Set.
Contract
A ConcurrentModificationError is thrown if the predicate modifies the set.
Example
final foo = {1, 2, 3, 4, 5};
final bar = foo.move(where: (e) => e.isEven).toSet();
print(foo); // {1, 3, 5}
print(bar); // {2, 4}
Implementation
@Possible({ConcurrentModificationError})
@useResult Set<E> toSet() {
final moved = <E>{};
collect(moved.add);
return moved;
}