user2949211
user2949211

Reputation: 1

Multi Dimensional Array in Scala

I am new to Scala and have run into a problem defining multi-dimensional arrays.

I have tried the following type specifications that did not compile:

val shortfall: Array[Array[Int]]= new Array (6,248)  
val shortfall= new  Array.ofDim[Int] (6,248)

The following specification compiled but does not allocate an instance of the array. The type spec for parameter passing was Array[Array[Int]].

val shortfall=  Array.ofDim[Int] (6,248)

I am converting a modeling application from Java with the following definition

int[][] shortfall = new int[6][248]

Upvotes: 0

Views: 199

Answers (1)

Brian
Brian

Reputation: 20295

scala> Array.ofDim[Int](6,248)
res0: Array[Array[Int]] = Array(Array(0, 0, 0, ...))

Upvotes: 2

Related Questions