Set<E>.of constructor

Set<E>.of(
  1. Iterable<E> elements
)

Creates a Set from elements.

The created Set is a LinkedHashSet. As such, it considers elements that are equal (using operator ==) to be indistinguishable, and requires them to have a compatible Object.hashCode implementation.

The set is equivalent to one created by LinkedHashSet<E>.of(elements).

final baseSet = <int>{1, 2, 3};
final setOf = Set<num>.of(baseSet);
print(setOf); // {1, 2, 3}

Implementation

factory Set.of(Iterable<E> elements) = LinkedHashSet<E>.of;