Your question and example will lead to a number of problems.
Do you really want to quit?
The Scala standard library approaches a certain length, trying to accommodate everything that the client passes as index arguments. In many cases, a negative index is interpreted as zero, and anything outside the collection size is simply ignored. See drop() and take() for examples.
Moreover, if you are going to scold the client for bad argument values, then it makes sense to test all the arguments received, even if one or the other becomes insignificant for the result.
assert() or require() ?
assert() has some advantages over require() , but the latter seems more suitable for the use you got here. You can read this for more information on the topic.
Rethink the wheel.
Scala already offers a dropElements method called patch .
def dropElements[T](array: Array[T], from: Int, howMany: Int) = { array.patch(from, Seq(), howMany) }
Except that it returns ArraySeq[T] instead of Array[T] . Arrays in Scala can be a bit of a pain this way.
strengthen-my-library
To make the new method look and look more Scala -like, you can "add" it to the Array library.
implicit class EnhancedArray[T](arr: Array[T]) { def dropElements(from: Int, howMany: Int): Array[T] = { arr.drop(from+howMany).copyToArray(arr,from) arr.dropRight(howMany) } } Array(1,1,1,8,8,7).dropElements(3,2) // res0: Array[Int] = Array(1, 1, 1, 7)