I have this simple code:
import java.util
import scala.collection.JavaConversions._
def f(x: util.List[Int]): Array[Int] = {
x.toArray[Int]
}
It is failing on error: missing arguments for method toArray in trait List
However the source code for toArray
is the following:
trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
...
def toArray[B >: A : ClassTag]: Array[B] = {
if (isTraversableAgain) {
val result = new Array[B](size)
copyToArray(result, 0)
result
}
else toBuffer.toArray
}
So clearly there is no missing argument.
1) How is that possible? Is there a simple workaround? Or am I missing something?
2) The error message continue with follow this method with '_' if you want to treat it as a partially applied function
. Don't you think it is a stupid proposition? I have declared the return value, so partially applied function cannot work. The compiler should see it.