Skip to content
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

MutableList print Unnormal in Scala REPL #8976

Closed
scabug opened this issue Nov 11, 2014 · 4 comments
Closed

MutableList print Unnormal in Scala REPL #8976

scabug opened this issue Nov 11, 2014 · 4 comments

Comments

@scabug
Copy link

scabug commented Nov 11, 2014

look the code in scala REPL:

scala> import scala.collection._
import scala.collection._

scala> val l = mutable.MutableList(1,2)
l: scala.collection.mutable.MutableList[Int] = MutableList(1, 2)

scala> val t = l.tail
t: scala.collection.mutable.MutableList[Int] = MutableList(2)

scala> l += 3
res0: l.type = MutableList(1, 2, 3)

// unnormal start here.....

scala> t.length
res3: Int = 1

// the t.length is 1, but why REPL print MutableList(2, 3)
scala> t
res1: scala.collection.mutable.MutableList[Int] = MutableList(2, 3)

// and t.toString print  MutableList(2)
scala> t.toString
res5: String = MutableList(2)
@scabug
Copy link
Author

scabug commented Nov 11, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8976?orig=1
Reporter: zavakid (zava)
Affected Versions: 2.11.2

@scabug
Copy link
Author

scabug commented Nov 11, 2014

@som-snytt said:
Just to answer the question, the tail iterator doesn't know how long it is.

scala> val it = t.iterator
it: Iterator[Int] = non-empty iterator

scala> it.next
res1: Int = 2

scala> it.next
res2: Int = 3

scala> it.hasNext
res3: Boolean = false

@scabug
Copy link
Author

scabug commented Nov 14, 2014

zavakid (zava) said:
@A. P. Marki
So you means the t's iterator and length has semantic conflict ?

@scabug
Copy link
Author

scabug commented Nov 14, 2014

@som-snytt said:
Psychic conflict.

scala/scala#4133

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants