I'm looking for an elegant way to select a range of elements in an Array to remove and return, mutating the original array. Javascript has a splice method that serves this purpose but I can't seem to find anything baked into Swift to achieve both steps:
var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
let oneTwoThree = array.removeAndReturn(0...2) // [1, 2, 3]
// array == [4, 5, 6, 7, 8, 9, 10]
I know about dropFirst(:), prefix(:) and removeSubrange(:) but they all either only return values without mutating the original array, or they mutate the original array without returning values.
Is there another baked-in method I've missed, or would I have to implement a custom extension/method to make this work?