Bob
Bob

Reputation: 10775

Valid nested loop in Java is not valid in Groovy

Following expression is valid in Java. Btw, I am also using Apache Commons Math

RealMatrix coefficients =
    new Array2DRowRealMatrix(new double[][] { { 2, 3, -2 }, { -1, 7, 6 }, { 4, -3, -5 } }, false);

But new double[][] { { 2, 3, -2 }, { -1, 7, 6 }, { 4, -3, -5 } } is invalid in Groovy. Why? And how it can be rewritten?

Upvotes: 0

Views: 54

Answers (1)

kpie
kpie

Reputation: 11080

you can do this

coefficients = [[2.0, 3.0, -2.0],[ -1.0, 7.0, 6.0 ],[ 4.0, -3.0, -5.0 ]] as double[][]

Upvotes: 2

Related Questions