New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two-argument indexOf does not work for Iterator #8552
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8552?orig=1 |
@ruippeixotog said (edited on May 17, 2014 10:18:25 PM UTC): def indexOf[B >: A](elem: B, from: Int): Int = indexWhere(elem == _, from) When scala> Iterator(5 -> 0).indexOf(5,0)
res0: Int = 0 |
@Ichoran said: |
@ruippeixotog said: |
@ruippeixotog said: |
Kevin Meredith (kevinmeredith) said (edited on Apr 16, 2015 4:49:08 PM UTC): I've noticed that other Iterator.scala code, as well as your PR, @rui, included var's. Why not implement override def indexWhere[B >: A](p: A => Boolean, from: Int): Int =
self.zipWithIndex.drop(from).find(p(_._1)) match {
case None => -1
case Some((_, index)) => index
} Note - I don't know if scala> Iterator(1,2,3).zipWithIndex.drop(0).find(_._1 == 3)
res2: Option[(Int, Int)] = Some((3,2)) |
@Ichoran said: |
@Ichoran said: |
Iterator(5).indexOf(5,0)
does not work. In fact, every call to the two-arg version ofindexOf
seems to return -1. I presume the iterator is being consumed completely instead of partially.The text was updated successfully, but these errors were encountered: