Daniele B
05/17/2021, 7:44 PMe.g. val list = listOf(3,9,1,6,7)
if I add a new 9, it would removes the old one:
list.add(9)
println(list) // listOf(3,1,6,7,9)
crummy
05/17/2021, 7:49 PMval set = setOf(3, 9, 1, 6, 7)
Daniele B
05/17/2021, 8:08 PMval set = mutableSetOf(3, 9, 1, 6, 7)
set.add(9)
println(set)
it still prints [3, 9, 1, 6, 7]ephemient
05/17/2021, 8:09 PMDaniele B
05/17/2021, 8:11 PMephemient
05/17/2021, 8:15 PMScott Kruse
05/17/2021, 10:57 PMpublic fun <T> Iterable<T>.distinct(): List<T> {
return this.toMutableSet().toList()
}
pretty convenient for a stdlib as it is