var a = arrayListOf<String>("hello","hello","lamine")
I need remove items match and reprint it again
CodePudding user response:
If you're trying to remove items that satisfy a particular condition, you just use removeAll
: a.removeAll { str -> matches(str) }
.
If you're trying to remove duplicates, you'll need an added Set
:
val deduped = a.toSet()
a.clear()
a.addAll(deduped)
or you can write
a = a.distinct()
if a
is a var
.