As I'm doing right now: `tipList = tipList.dropAt(...
# announcements
k
As I'm doing right now:
tipList = tipList.dropAt(index)
d
If all you need is a sequence, you could do something like:
inline fun <T : Any> List<T>.dropAt(index: Int): Sequence<T> = buildSequence { yield(subList(0, index)); yield(subList(index + 1, size)) }
or similar with generateSequence...
k
Don't you need to actually
yield
values instead of partial lists? Unfortunately I do need an actual list, I need to "modify" an immutable list variable in-place.
d
Oops youre right, you need yieldAll, not yield...
k
That exists too? I should really learn about everything coroutine-related sometime...
d
Yup, it exists... its worth it to read the docs on kotlinx.coroutines... its pretty good!
If you need it immutable because of concurrency, you could also maybe use a mutable list and check out: https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md#actors ...