Question: I'm trying to find something equivalent to `remove_range` (which does not exist of course) as shown below. Seems there is no easy way to implement this functionality.

```
a = [0,2,8,2,4,5,]
b = a.remove_range(1,2) #remove items between index 1 and 2 ,inclusively
#expect b == [0,2,4,5]
b = a.remove_range(3,4)
#expect b == [0,2,8,5]

```

**Please test at least above two cases before posting your solution :)** 

Suppose the size of the range is M, this operation should requires O(1) space and O(N-M) time complexity.

EDIT:
I see people keep posting the `a - a[range]`. But it is not correct, that is to remove the elements exists in a[range], not to remove the the element belongs to range.

`a - a[1..2]` will return `[0, 4, 5]`. However,we want to keep the 3rd element which is `2`.

Answer: 
This is built into the array class. Just subtract the piece that you don't want:

```
2.0.0-p353 :001 > ar = [0,2,8,2,4,5]
=> [0, 2, 8, 2, 4, 5] 
2.0.0-p353 :002 > ar - ar[2..3]
=> [0, 4, 5] 

```
```
a = [0,2,8,2,4,5]    
j = 1

(3..4).each do |i|
    j == 1 ? a.delete_at(i) : a.delete_at(i-1)
    j += 1
end

b = a
[0, 2, 8, 5]

```