blob: 64e92590727eeafafedd60c0ea576d424c278235 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)
}
}
|