Created
March 25, 2020 21:24
-
-
Save tailorvj/a756c979a2b9cf29ae2df00b0e6170b4 to your computer and use it in GitHub Desktop.
Dart: Convert Set to List and back again using Set.toList() and List.toSet() methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| main() { | |
| Set<String> nameSet = {'Rita', 'Alex', 'Sam', 'Eva'}; | |
| print('nameSet: $nameSet\n'); //{Rita, Alex, Sam, Eva} | |
| List<String> nameList = nameSet.toList(); | |
| print('nameList: $nameList\n'); //[Rita, Alex, Sam, Eva] | |
| Set<String> nameSet2 = nameList.toSet(); | |
| print('nameSet2: $nameSet2\n'); //{Rita, Alex, Sam, Eva} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment