diff options
author | Paul Phillips <paulp@improving.org> | 2010-12-31 08:52:12 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-12-31 08:52:12 +0000 |
commit | 1259651a7ded65809d63d6b2744d4d097cc90ead (patch) | |
tree | a1cecb7281c3aad8f00fdd20d85474feb77c8e36 /test/files | |
parent | 740fcf90bd7bfe4d4c322d2c7912e4df04200d90 (diff) | |
download | scala-1259651a7ded65809d63d6b2744d4d097cc90ead.tar.gz scala-1259651a7ded65809d63d6b2744d4d097cc90ead.tar.bz2 scala-1259651a7ded65809d63d6b2744d4d097cc90ead.zip |
Even after the mostly blissful marriage of Trav...
Even after the mostly blissful marriage of Traversable and Iterator
there was some fussin' and fightin' over who should have to care for
Option. Now there is peace among the collections once again.
// before
scala> Iterator(Some(1), None).flatten
<console>:6: error: value flatten is not a member of Iterator[Option[Int]]
// after
scala> Iterator(Some(1), None).flatten
res0: Iterator[Int] = non-empty iterator
Review by moors.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/flat-flat-flat.scala | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/files/run/flat-flat-flat.scala b/test/files/run/flat-flat-flat.scala new file mode 100644 index 0000000000..80868b9c5e --- /dev/null +++ b/test/files/run/flat-flat-flat.scala @@ -0,0 +1,11 @@ +object Test { + def f1 = List(Iterator(Some(1), None, Some(2)), Iterator(Some(3), None)) + def f2 = Iterator(List(Some(1), None, Some(2)), List(Some(3), None), Nil) + def f3 = List(Some(Iterator(1)), None, Some(Iterator(2, 3))) + + def main(args: Array[String]): Unit = { + assert(f1.flatten.flatten.toList == List(1, 2, 3)) + assert(f2.flatten.flatten.toList == List(1, 2, 3)) + assert(f3.flatten.flatten.toList == List(1, 2, 3)) + } +} |