scala> List(1,2,3) endsWith List(2, "I AM GOZER THE DESTROYER")
res0: Boolean = true ... is fixed. git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@18331 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
d11f1fed92
commit
96d2a5cd5a
|
@ -283,11 +283,12 @@ trait SequenceTemplate[+A, +This <: IterableTemplate[A, This] with Sequence[A]]
|
|||
* @see String.startsWith
|
||||
*/
|
||||
def startsWith[B](that: Sequence[B], offset: Int): Boolean = {
|
||||
val i = this.iterator.drop(offset)
|
||||
val i = this.iterator drop offset
|
||||
val j = that.iterator
|
||||
while (j.hasNext && i.hasNext) {
|
||||
if (i.next != j.next) return false
|
||||
}
|
||||
while (j.hasNext && i.hasNext)
|
||||
if (i.next != j.next)
|
||||
return false
|
||||
|
||||
!j.hasNext
|
||||
}
|
||||
|
||||
|
@ -305,7 +306,10 @@ trait SequenceTemplate[+A, +This <: IterableTemplate[A, This] with Sequence[A]]
|
|||
def endsWith[B](that: Sequence[B]): Boolean = {
|
||||
val i = this.iterator.drop(length - that.length)
|
||||
val j = that.iterator
|
||||
while (i.hasNext && j.hasNext && i.next == j.next) ()
|
||||
while (i.hasNext && j.hasNext)
|
||||
if (i.next != j.next)
|
||||
return false
|
||||
|
||||
!j.hasNext
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue