https://kotlinlang.org logo
#getting-started
Title
# getting-started
v

vlad.minaev

09/19/2020, 8:52 AM
dumb question - are there any collection method which works as opposite to .slice ? (e.g. returns collection with elements removed at specified range)
e

ephemient

09/19/2020, 9:00 AM
mutableList.subList(startInclusive, endExclusive).clear()
will remove
.slice(startInclusive until endExclusive)
in-place, if that's what you're looking for
on an immutable list, there's not really anything pre-made...
list.take(startInclusive) + list.drop(endExclusive)
would work though
v

vlad.minaev

09/19/2020, 9:04 AM
Yep I want it on immutable list
thanks
n

nanodeath

09/19/2020, 2:28 PM
you might also try
filterIndexed
1
3 Views