<@U0F8Y5E5A> `val newList = list.minusIndex(i)`
# stdlib
l
@mg6maciej
val newList = list.minusIndex(i)
👍 1
m
Thanks again 😉
l
You're welcome. Now, let's implement it 😉
m
Hmm. You tricked me!
l
Here you go:
fun<E> List<E>.minusIndex(index: Int) = minus(this[index])
m
No, this is wrong.
It can remove element at different index.
fun <T> List<T>.minusIndex(index: Int) = take(index) + drop(index + 1)
I added this to my commons.
Could also use
subList
instead as it doesn't create tmp lists.
l
Here you go:
fun<E> List<E>.minusIndex(index: Int) = subList(0, index) + subList(index + 1, size)
m
🙂