Logo

Programming-Idioms

History of Idiom 118 > diff from v70 to v71

Edit summary for version 71 by programming-idioms.org:
Fix dartpad demo link

Version 70

2022-09-05, 12:35:38

Version 71

2023-10-31, 21:24:10

Idiom #118 List to set

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

Turning the list [a,b,c,b] into the set {c,a,b}

Idiom #118 List to set

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

Turning the list [a,b,c,b] into the set {c,a,b}
Variables
y,x
Variables
y,x
Code
var y = x.toSet();
Code
var y = x.toSet();
Comments bubble
List<T> has a method to convert directly to Set<T>.
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
Doc URL
https://api.dart.dev/stable/2.4.0/dart-core/Set-class.html
Demo URL
https://dartpad.dev/6c647bf2dc2cc2e7bb5516e08fa7330c
Demo URL
https://dartpad.dev/?id=6c647bf2dc2cc2e7bb5516e08fa7330c