How can we remove items from specify position to e...
# getting-started
s
How can we remove items from specify position to end? for example:
Copy code
list: ["a", "b", "c", "d", "e", "f", "g"]
give specify position: 3
result: ["a", "b", "c"]
e
what do you want to do?
list.take(3)
,
list.slice(0..2)
return a new list with a subset of elements
list.subList(0, 3)
returns a view of the original list
mutableList.subList(3, mutableList.size).clear()
removes the tail from a mutable list
s
If the list is
val data: MutableList<String>
How to modify val
data
list?
I will try
subList
. thx