Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala error: '=' expected but ';' found

Not sure what caused this problem: error: '=' expected but ';' found.

val vectors = filtered_data_by_key.map( x => {
    var temp
    x._2.copyToArray(temp)  // Error occurs here
    (x._1, temp)
})
like image 860
Jiang Xiang Avatar asked Jan 14 '15 20:01

Jiang Xiang


1 Answers

var temp isn't a statement.

If you're trying to declare temp without assigning anything to it, do

var temp :Array[_] = _

But is temp supposed to be an array? then try var temp = Array(). temp needs something assigned to it before being passed into copyToArray. Also as you're not destructively assigning to temp it doesn't need to be a var.

like image 130
George Simms Avatar answered Oct 18 '22 04:10

George Simms