summaryrefslogtreecommitdiff
path: root/test/files/run/withIndex.scala
diff options
context:
space:
mode:
authorLex Spoon <lex@lexspoon.org>2006-05-05 11:49:08 +0000
committerLex Spoon <lex@lexspoon.org>2006-05-05 11:49:08 +0000
commit1f5bd8a590e9c29fdaabb53adeae1bf5c22258f4 (patch)
treef8d798227ef16cca1b0c91d0680f05f849516cc2 /test/files/run/withIndex.scala
parent5a94352a620b652bafe8386adf2637f4bec86e25 (diff)
downloadscala-1f5bd8a590e9c29fdaabb53adeae1bf5c22258f4.tar.gz
scala-1f5bd8a590e9c29fdaabb53adeae1bf5c22258f4.tar.bz2
scala-1f5bd8a590e9c29fdaabb53adeae1bf5c22258f4.zip
added zipWithIndex to several collection classes
Diffstat (limited to 'test/files/run/withIndex.scala')
-rw-r--r--test/files/run/withIndex.scala22
1 files changed, 22 insertions, 0 deletions
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)
+ }
+}