Hello!
I am new to the forum and to Scala.
Excuse me in advance if I ask an obvious question.
I was looking at the following code:
def reduceLeft[B >: A](op: (B, A) => B): B = {
if (isEmpty)
throw new UnsupportedOperationException("empty.reduceLeft")
var first = true
var acc: B = 0.asInstanceOf[B]
for (x <- self) {
if (first) {
acc = x
first = false
}
else acc = op(acc, x)
}
acc
}
And I was wondering if it is possible to iterate manually, using next() and hasNext (instead of using for( <-)), in the context of TraversableOnce.
Thanks and regards,
Fernando Pelliccioni.