You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@cvogt said:
The suggested fix is broken. It always drops the first element, as go is always false in the first iteration. The following should implement the request correctly (notice the added !go && ):
defdropWhile(p: A=>Boolean):Repr= {
valb= newBuilder
vargo=falsefor (x <-this) {
if (!go &&!p(x)) go =trueif (go) b += x
}
b.result
}
Notice that this changes the semantics with regard to side effects of predicate p.
scala.collection.TraversableLike:
If the predicate
p
is an expensive computation than it unnecessarily slowsdropWhile
down aftergo
istrue
.Suggestion:
The text was updated successfully, but these errors were encountered: