removeAt
Removes an element at the specified index from the list.
All elements placed after index are shifted 1 position left.
Since Kotlin
1.1Return
the element that has been removed.
Throws
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
list.removeAt(1)
println(list) // [a, c]
list.removeAt(0)
println(list) // [c]
// list.removeAt(1) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Removes an element at the specified index from the list.
This method is redeclared as abstract, because it's not implemented in the base class, so it must be always overridden in the concrete mutable collection implementation.
Since Kotlin
1.1Return
the element that has been removed.
Removes an element at the specified index from the list.
All elements placed after index are shifted 1 position left.
Since Kotlin
1.3Return
the element that has been removed.
Throws
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
list.removeAt(1)
println(list) // [a, c]
list.removeAt(0)
println(list) // [c]
// list.removeAt(1) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Removes an element at the specified index from the list.
All elements placed after index are shifted 1 position left.
Since Kotlin
1.8Return
the element that has been removed.
Throws
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
list.removeAt(1)
println(list) // [a, c]
list.removeAt(0)
println(list) // [c]
// list.removeAt(1) // will fail with IndexOutOfBoundsException
//sampleEnd
}
Removes an element at the specified index from the list.
All elements placed after index are shifted 1 position left.
Since Kotlin
1.8Return
the element that has been removed.
Throws
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = mutableListOf('a', 'b', 'c')
list.removeAt(1)
println(list) // [a, c]
list.removeAt(0)
println(list) // [c]
// list.removeAt(1) // will fail with IndexOutOfBoundsException
//sampleEnd
}