diff options
author | Rex Kerr <ichoran@gmail.com> | 2015-08-30 17:27:05 -0700 |
---|---|---|
committer | Rex Kerr <ichoran@gmail.com> | 2015-08-30 17:27:05 -0700 |
commit | 2c16790ae48debe6e8b07b7ece86b0c665359cfd (patch) | |
tree | 8c3ac3916aec0d33d3fca4f570dfd1f73d29bc57 /src/library | |
parent | 4f35ab77e6b4456025facc63297e7f2e93c2b9d0 (diff) | |
download | scala-2c16790ae48debe6e8b07b7ece86b0c665359cfd.tar.gz scala-2c16790ae48debe6e8b07b7ece86b0c665359cfd.tar.bz2 scala-2c16790ae48debe6e8b07b7ece86b0c665359cfd.zip |
SI-9379 Added toString to .zipped to allow Stream etc to short-circuit
Tuple2Zipped and Tuple3Zipped would try to compute a hash code when .toString was called on them. This overrides toString to print (collection1, collection2).zipped instead, using the collection's own toString method. This allows collections that have a toString but not a hashCode (such as Iterator.from(0) and s = 1 #:: s) to print out as they usually do.
JUnit test to verify the deferral to collections' .toString.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/runtime/Tuple2Zipped.scala | 2 | ||||
-rw-r--r-- | src/library/scala/runtime/Tuple3Zipped.scala | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala index 512c4fbc27..1c432b0403 100644 --- a/src/library/scala/runtime/Tuple2Zipped.scala +++ b/src/library/scala/runtime/Tuple2Zipped.scala @@ -110,6 +110,8 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1 return } } + + override def toString = "(%s, %s).zipped".format(colls._1.toString, colls._2.toString) } object Tuple2Zipped { diff --git a/src/library/scala/runtime/Tuple3Zipped.scala b/src/library/scala/runtime/Tuple3Zipped.scala index ffd44acf81..3bab86921b 100644 --- a/src/library/scala/runtime/Tuple3Zipped.scala +++ b/src/library/scala/runtime/Tuple3Zipped.scala @@ -118,6 +118,8 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers return } } + + override def toString: String = "(%s, %s, %s).zipped".format(colls._1.toString, colls._2.toString, colls._3.toString) } object Tuple3Zipped { |