diff options
author | Lex Spoon <lex@lexspoon.org> | 2006-05-05 11:49:08 +0000 |
---|---|---|
committer | Lex Spoon <lex@lexspoon.org> | 2006-05-05 11:49:08 +0000 |
commit | 1f5bd8a590e9c29fdaabb53adeae1bf5c22258f4 (patch) | |
tree | f8d798227ef16cca1b0c91d0680f05f849516cc2 /test | |
parent | 5a94352a620b652bafe8386adf2637f4bec86e25 (diff) | |
download | scala-1f5bd8a590e9c29fdaabb53adeae1bf5c22258f4.tar.gz scala-1f5bd8a590e9c29fdaabb53adeae1bf5c22258f4.tar.bz2 scala-1f5bd8a590e9c29fdaabb53adeae1bf5c22258f4.zip |
added zipWithIndex to several collection classes
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/withIndex.check | 7 | ||||
-rw-r--r-- | test/files/run/withIndex.scala | 22 |
2 files changed, 29 insertions, 0 deletions
diff --git a/test/files/run/withIndex.check b/test/files/run/withIndex.check new file mode 100644 index 0000000000..75495f171b --- /dev/null +++ b/test/files/run/withIndex.check @@ -0,0 +1,7 @@ +List((a,0),(b,1),(c,2)) +List((a,0),(b,1),(c,2)) +List((a,0),(b,1),(c,2)) +List((a,0),(b,1),(c,2)) +List() +List() +List() diff --git a/test/files/run/withIndex.scala b/test/files/run/withIndex.scala new file mode 100644 index 0000000000..64e9259072 --- /dev/null +++ b/test/files/run/withIndex.scala @@ -0,0 +1,22 @@ +object Test { + def main(args: Array[String]) = { + val ary: Array[String] = Array("a", "b", "c") + val lst: List[String] = List("a", "b", "c") + val itr: Iterator[String] = lst.elements + val str: Stream[String] = Stream.fromIterator(lst.elements) + + Console.println(ary.zipWithIndex.toList) + Console.println(lst.zipWithIndex.toList) + Console.println(itr.zipWithIndex.toList) + Console.println(str.zipWithIndex.toList) + assert(ary.zipWithIndex.isInstanceOf[Array[Pair[String,Int]]]) + + val emptyArray = new Array[String](0) + val emptyList: List[String] = Nil + val emptyIterator = emptyList.elements + + Console.println(emptyArray.zipWithIndex.toList) + Console.println(emptyList.zipWithIndex.toList) + Console.println(emptyIterator.zipWithIndex.toList) + } +} |