Logo

Programming-Idioms

History of Idiom 119 > diff from v62 to v63

Edit summary for version 63 by alvarobrey:
[Kotlin] Ordering is not preserved when converted into a set, and also the conversion back to List was missing

Version 62

2019-09-27, 13:09:56

Version 63

2019-09-27, 13:26:29

Idiom #119 Deduplicate list

Remove duplicates from list x.
Explain if original order is preserved.

Illustration

Idiom #119 Deduplicate list

Remove duplicates from list x.
Explain if original order is preserved.

Illustration
Extra Keywords
deduplicate dupe dupes redundant redundancy undupe
Extra Keywords
deduplicate dupe dupes redundant redundancy undupe
Code
val duplicates = listOf("b", "a", "b", "c")
val noDuplicates = duplicates.toSet()
Code
val duplicates = listOf("b", "a", "b", "c")
val noDuplicates = duplicates.toSet().toList()
Comments bubble
original ordering is preserved
Comments bubble
original ordering is not preserved