EDIT / UPDATE: PROBLEM IS FIXED!
This is kinda strange as iterating over collections in Scala is usually straight forward but I do get a compile error while using an double array from a case class. The error says:
error: value foreach is not a member of Array[Double] for(d <- data.data_arr)
okay, here is the case class:
case class StatsData (name: String,
timeUnit: TimeUnit,
data_arr: Array[Double],
min: Double,
max: Double){}
And here is the critical point:
/*Doesn't work */
for(d <- data.data_arr) {
println(d) // can't fetch value d here
number = new Number(col, row, d)
}
Strange thing is, no matter what kind of iteration I'm using, it simply doesn't work. For example using array index
for (i <- data_arr.length-1)
as well as converting the array to a sequence throws exactly the same error as above;
for(d <- data.data_arr.toSeq)
What am I doing wrong?
Thanks for any help on this matter.
EDIT / UPDATE: PROBLEM IS FIXED!
As it turns out, the cause of the problem was an issue within IntelliJ's Project settings or structure, I cannot say it for certain but it was all solved by creating a new project. The same code runs now perfectly fine. Sorry for that but nearly all of the post has helped me to trace the issue down.
@yakshaver
What is the "yield" expression exactly used for?
Thanks for all the help.
foreach
is a member ofArrayOps
notArray
—but that's weird that it isn't finding the implicit conversion fromPredef
. Try explicitly importingscala.Predef.doubleArrayOps
(or calling it directly) and see if that fixes the problem. That should help with the diagnosis... – DaoWenscala.Predef.doubleArrayOps
– DaoWen