Since Scala does not have old Java style for loops with index,
for
// does not work val xs = Array(\"first\", \"second\", \"third\") for (i=0; i<
One more way:
scala> val xs = Array("first", "second", "third") xs: Array[java.lang.String] = Array(first, second, third) scala> for (i <- xs.indices) | println(i + ": " + xs(i)) 0: first 1: second 2: third