Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scala 2 dimensional array

This may sound easy, but I just can't get it right.

How to create a 2 dimensional array with size 100 by 60 in Scala? Supposed I have class called Abcd and I want to create a 2 dimensional array of Abcd. I tried with the following code but doesn't work.

var myArray = new Array[Array[Abcd]](100,60)

It complains "too many arguments for constructor Array"

like image 360
Wins Avatar asked Apr 02 '13 01:04

Wins


1 Answers

The currently recommended way is to use ofDim:

var myArray = Array.ofDim[Abcd](100, 60)
like image 138
Alex Yarmula Avatar answered Oct 20 '22 13:10

Alex Yarmula