toMutableSet method

Set<T> toMutableSet()

Converts the current Set to a mutable Set.

Returns a new mutable Set containing the same elements as the original Set.

Example:

Set<int> numbers = {1, 2, 3};
Set<int> mutableNumbers = numbers.toMutableSet();
mutableNumbers.add(4);
print(mutableNumbers); // Output: {1, 2, 3, 4}

Implementation

Set<T> toMutableSet() => Set.from(this);