Hi all, is there any operator function to insert a...
# random
s
Hi all, is there any operator function to insert a list to another list at a particular index that returns the new list?
r
There’s a version of
addAll
which takes an index as first parameter
s
but it mutates the list
and requires a mutable list
r
If you want to create another list then you need to do just that
Something like
src.take(index) + elements + src.last(src.size - index)
(this creates a useless intermediate list)
But if I were you I would create a slightly longer and better optimized extension than this
s
ya makes sense. I thought we had a extension fn for that in std lib 😛