summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/IterableViewLike.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-11-29 23:00:07 +0000
committerPaul Phillips <paulp@improving.org>2010-11-29 23:00:07 +0000
commit66a92814a61c62149a49335f65f4189763b43296 (patch)
tree981508efdd7a29daa12f3e121d9608e441f26ece /src/library/scala/collection/IterableViewLike.scala
parent4ec7f11a799444c3758e94b3fdf9fa5c26330577 (diff)
downloadscala-66a92814a61c62149a49335f65f4189763b43296.tar.gz
scala-66a92814a61c62149a49335f65f4189763b43296.tar.bz2
scala-66a92814a61c62149a49335f65f4189763b43296.zip
The initial implementation of TraversableOnce c...
The initial implementation of TraversableOnce could not supply concrete methods or even signatures for map and flatMap because they have different signatures in Iterator and TraversableLike. But we can take another approach which works out as nicely: 1) Create implicits which install those methods and flatten on TraversableOnce instances. 2) Generalize the signatures of flatten and flatMap to work with A => TraversableOnce[B] instead of A => Traversable[B]. And voila, you can mix and match Iterators and Traversables in a for comprehension, map, flatMap, and flatten, without the tedious process of sprinkling .iterator or .toList around to appease the compiler. No review.
Diffstat (limited to 'src/library/scala/collection/IterableViewLike.scala')
-rw-r--r--src/library/scala/collection/IterableViewLike.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/library/scala/collection/IterableViewLike.scala b/src/library/scala/collection/IterableViewLike.scala
index 9f77c6965b..a7578e9a01 100644
--- a/src/library/scala/collection/IterableViewLike.scala
+++ b/src/library/scala/collection/IterableViewLike.scala
@@ -109,7 +109,7 @@ extends Iterable[A] with IterableLike[A, This] with TraversableView[A, Coll] wit
protected override def newForced[B](xs: => Seq[B]): Transformed[B] = new Forced[B] { val forced = xs }
protected override def newAppended[B >: A](that: Traversable[B]): Transformed[B] = new Appended[B] { val rest = that }
protected override def newMapped[B](f: A => B): Transformed[B] = new Mapped[B] { val mapping = f }
- protected override def newFlatMapped[B](f: A => Traversable[B]): Transformed[B] = new FlatMapped[B] { val mapping = f }
+ protected override def newFlatMapped[B](f: A => TraversableOnce[B]): Transformed[B] = new FlatMapped[B] { val mapping = f }
protected override def newFiltered(p: A => Boolean): Transformed[A] = new Filtered { val pred = p }
protected override def newSliced(_from: Int, _until: Int): Transformed[A] = new Sliced { val from = _from; val until = _until }
protected override def newDroppedWhile(p: A => Boolean): Transformed[A] = new DroppedWhile { val pred = p }