Reputation: 44061
So far I have
def toDoubleArray(list: ArrayList<Double>): Array[Double] {
...
}
Which is not compiling and is underlined but giving a very cryptic error message
Upvotes: 2
Views: 4338
Reputation: 17369
import scala.collection.JavaConversions._
def toDoubleArray(list: ArrayList[Double]): Array[Double] = list.toArray
import will allow automatic conversion of Java ArrayList to scala ListBuffer ArrayBuffer
More generic solution:
def [T] toDoubleArray(list: ArrayList[T]): Array[T] = list.toArray
But in reality you don't even need a function to do that.
Upvotes: 6