Download Getting Started with Scala 26-Jul-16

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Transcript
Multidimensional arrays

To create a 2-dimensional array or higher, you need to use the
toDim method


scala> val twoDim = Array.ofDim[Int](2, 3)
twoDim: Array[Array[Int]] = Array(Array(0, 0, 0),
Array(0, 0, 0))
Once created, it’s used very much like an array in Java (but with
parentheses rather than brackets)

scala> twoDim(1)(2) = 99

scala> twoDim
res2: Array[Array[Int]] = Array(Array(0, 0, 0),
Array(0, 0, 99))