difference 方法

Set<String> difference(
  1. Set<Object?> other
)
继承

创建一个新的集合,包含本集合中不在 other 中的元素。

也就是说,返回的集合包含本 Set 中所有不是 other 元素的元素,根据 other.contains 进行判断。

final characters1 = <String>{'A', 'B', 'C'};
final characters2 = <String>{'A', 'E', 'F'};
final differenceSet1 = characters1.difference(characters2);
print(differenceSet1); // {B, C}
final differenceSet2 = characters2.difference(characters1);
print(differenceSet2); // {E, F}

实现

Set<String> difference(Set<Object?> other) => readClasses().difference(other);