Collections
Vector Indexing
Read a value from a vector by index.
Vector Indexing
VectorIndexing.scala
object Main {
def main(args: Array[String]): Unit = {
val index =
val colors = Vector("red", "green", "blue")
val chosen = colors(index)
println("index=" + index)
println("chosen=" + chosen)
}
}
object Main {
def main(args: Array[String]): Unit = {
val index =
val colors = Vector("red", "green", "blue")
val chosen = colors(index)
println("index=" + index)
println("chosen=" + chosen)
}
}
object Main {
def main(args: Array[String]): Unit = {
val index =
val colors = Vector("red", "green", "blue")
val chosen = colors(index)
println("index=" + index)
println("chosen=" + chosen)
}
}
vector-indexing
A vector supports index reads. Index zero reads the first element.