diff options
author | Paul Phillips <paulp@improving.org> | 2011-03-31 22:18:43 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-03-31 22:18:43 +0000 |
commit | 0444357cd5eae4efb401bb8a59c3794db2d1b2db (patch) | |
tree | 11baefa4bfc292343ae12e06f846d930a39bcbcc | |
parent | fe0e4b473fe45157bd59012e5e44e87c8f1b99b0 (diff) | |
download | scala-0444357cd5eae4efb401bb8a59c3794db2d1b2db.tar.gz scala-0444357cd5eae4efb401bb8a59c3794db2d1b2db.tar.bz2 scala-0444357cd5eae4efb401bb8a59c3794db2d1b2db.zip |
A quick fix for the weird string output one get...
A quick fix for the weird string output one gets in the repl when
calling .par. No review.
-rw-r--r-- | src/library/scala/runtime/ScalaRunTime.scala | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index b4928c2a26..41a63777c5 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -287,14 +287,18 @@ object ScalaRunTime { case (k, v) => inner(k) + " -> " + inner(v) case _ => inner(arg) } - // The recursively applied attempt to prettify Array printing + // The recursively applied attempt to prettify Array printing. + // Note that iterator is used if possible and foreach is used as a + // last resort, because the parallel collections "foreach" in a + // random order even on sequences. def inner(arg: Any): String = arg match { case null => "null" case "" => "\"\"" case x: String => if (x.head.isWhitespace || x.last.isWhitespace) "\"" + x + "\"" else x - case x if useOwnToString(x) => x.toString + case x if useOwnToString(x) => x toString case x: AnyRef if isArray(x) => WrappedArray make x take maxElements map inner mkString ("Array(", ", ", ")") - case x: collection.Map[_, _] => x take maxElements map mapInner mkString (x.stringPrefix + "(", ", ", ")") + case x: collection.Map[_, _] => x.iterator take maxElements map mapInner mkString (x.stringPrefix + "(", ", ", ")") + case x: Iterable[_] => x.iterator take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")") case x: Traversable[_] => x take maxElements map inner mkString (x.stringPrefix + "(", ", ", ")") case x: Product1[_] if isTuple(x) => "(" + inner(x._1) + ",)" // that special trailing comma case x: Product if isTuple(x) => x.productIterator map inner mkString ("(", ",", ")") |