Answers for "kotlin list remove"

0

kotlin list remove

val nums = mutableListOf(-3, -2, 4, -1, 0, 1, 2, 3, 4, 2, 5, 6, 5, 8)

nums.removeAt(4)
// [-3, -2, 4, -1, 1, 2, 3, 4, 2, 5, 6, 5, 8]

nums.remove(4)
// [-3, -2, -1, 1, 2, 3, 4, 2, 5, 6, 5, 8]

nums.removeAll(listOf(1, 2, 3))
// [-3, -2, -1, 4, 5, 6, 5, 8]

nums.removeAll({ it < -1 })
// [-1, 4, 5, 6, 5, 8]

nums -= listOf(4, 5)
// [-1, 6, 8]

nums.removeAt(0) // remove first element
// [6, 8]

nums.removeAt(nums.size - 1) // remove last element
// [6]

nums.clear()
// []
Posted by: Guest on August-10-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language