Extends Scala iterator's drop method to allow for drop(x: Long) I have a need to drop quantities of elements from an iterator beyond Int.MaxValue so I wrote a helper function that does just that. However, I can't help but feel like I'm doing this the dumb way - that there's got to be some built-in language construct or at least a more elegant way of tackling the problem.

/**
 * drops a Long's worth of elements from an Iterator[T] and returns the succeeding element.
 * 
 * @param dropVal is the number of elements we want to drop
 * @param iteratorLong is the the iterator from which you want to drop lots-o-elements
 * 
 * @return the value you need 
 */
def dropLongAndGet[T](dropVal: Long, iteratorLong: Iterator[T]): T = {    
    val dropCount = dropVal / Int.MaxValue
    val dropCountRemainder = (dropVal % Int.MaxValue).toInt

    var localIteratorReference = iteratorLong
    for (i &lt;- 0L until dropCount) {
        localIteratorReference = iteratorLong.drop(Int.MaxValue)
    }

    return localIteratorReference.drop(dropCountRemainder)
                                 .next     
}


Also, I am aware that the code will work w/o the return keyword - I use it because I'm used to seeing it from Java, it doesn't hurt anything to have it there, and I think it helps non-Scala programmers make sense of what's going on if/when they have to read my code.
You can use a (tail-)recursive method to achieve same result:

def drop[T](c: Long, i: Iterator[T]): Iterator[T] = {
  if (c &gt; Int.MaxValue) drop(c - Int.MaxValue, i.drop(Int.MaxValue))
  else i.drop(c.toInt)
}

def dropLongAndGet[T](dropVal: Long, iteratorLong: Iterator[T]): T = {
  drop(dropVal, iteratorLong).next
}