Busti
Busti

Reputation: 5604

Multidimensional array in Scala

Is it possible to create a multidimensional array in scala without using the "Array()"

Like this in java:

int[][] myIntArray = {
    {1, 2, 3},
    {4, 5, 6},
    {7, 8, 9}
};

Upvotes: 1

Views: 237

Answers (1)

JosEduSol
JosEduSol

Reputation: 5436

If i understood correctly, you dont want to declare the array repeating Array a lot of times.

You can try this:

val > = Array

val x: Array[Array[Int]] = >(
  >(1, 2, 3),
  >(4, 5, 6),
  >(7, 8, 9)
)

Source (There are other suggestions also)

Upvotes: 8

Related Questions