summaryrefslogtreecommitdiff
path: root/test/files/pos/iterator-traversable-mix.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 /test/files/pos/iterator-traversable-mix.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 'test/files/pos/iterator-traversable-mix.scala')
-rw-r--r--test/files/pos/iterator-traversable-mix.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/files/pos/iterator-traversable-mix.scala b/test/files/pos/iterator-traversable-mix.scala
new file mode 100644
index 0000000000..2d6bf44c70
--- /dev/null
+++ b/test/files/pos/iterator-traversable-mix.scala
@@ -0,0 +1,8 @@
+object Test {
+ for {
+ x1 <- List(1, 2)
+ x2 <- Iterator(3, 4)
+ x3 <- Seq(5, 6).iterator
+ x4 <- Stream(7, 8)
+ } yield x1+x2+x3+x4
+}