I have a list as follows:
val internalIdList: List[Int] = List()
internalIdList = List(11, 12, 13, 14, 15)
From this list would remove the third element in order to obtain:
internalIdList = List(11, 12, 14, 15)
I can not use a ListBuffer
, are obliged to maintain the existing structure.
How can I do?
Thanks to all
Simply use
val trunced = internalIdList.take(index) ++ internalIdList.drop(index + 1)
This will also work if index is larger than the size of the list (It will return the same list).