# toSet method

1. @override

Set<E> toSet()
override

Creates a Set containing the same elements as this iterable.

The set may contain fewer elements than the iterable, if the iterable contains an element more than once, or it contains one or more elements that are equal. The order of the elements in the set is not guaranteed to be the same as for the iterable.

Example:

    final planets = <int, String>{1: 'Mercury', 2: 'Venus', 3: 'Mars'};
    final valueSet = planets.values.toSet(); // {Mercury, Venus, Mars}

## Implementation

    @override
    Set<E> toSet() {
      final Set<E> set = {}; // Using built-in Set for simplicity here
      forEach((element) => set.add(element));
      return set;
    }