Set Relationship

Set Relationship

sets are collections of unique elements, and you can perform various operations on sets to establish relationships between them.

  • Subset Relationship

Example

void main() {
  Set<int> setA = {1, 2};
  Set<int> setB = {1, 2, 3, 4};
  bool isSubset = setB.containsAll(setA); // true, setA is a subset of setB
  print(isSubset);
}

Output

true
  • quality Relationship

Example

void main(){
     Set<int> set1 = {1, 2, 3};
     Set<int> set2 = {3, 1, 2};
     bool isEqual = set1 == set2; // true, set1 and set2 are equal
     print(isEqual);
}

Output

false