Logo

Programming-Idioms

History of Idiom 118 > diff from v34 to v35

Edit summary for version 35 by kuef:
New Dart implementation by user [kuef]

Version 34

2019-02-02, 05:08:30

Version 35

2019-06-28, 10:39:54

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Illustration

Idiom #118 List to set

Create set y from list x.
x may contain duplicates. y is unordered and has no repeated values.

Illustration
Code
void main() {
  List<int> list = [1,2,3,4,5];
  list.toSet(); 
  print(list);
}
Comments bubble
List<T> has a method to convert directly to Set<T>.
Doc URL
https://api.dart.dev/stable/2.4.0/dart-core/Set-class.html