Hi, is there some collection api that trims a muta...
# getting-started
u
Hi, is there some collection api that trims a mutable list to a size? I know
take
but that creates a new list
d
You can't trim a
MutableList
(because abstraction, what does trim mean for a linked list?) but you can trim an
ArrayList
.
k
What? Just remove the last elements, right?
d
I was thinking about making capacity == length.
u
problem was the iterator mostly and the concurrent modification exception, so ill assume ArrayList instead of mutablelist and just iterate via indices from end backwards, should work, thanks
k
No the proper solution is get a sublist and
clear()
that.