It seems I don\'t understand something important, maybe about erasure (damn it).
I have a method, which I wanted to create array of size n
filled with value
That is because in testArray
the concrete type of T
is not known at compile time. Your signature has to look like def testArray[T : ClassManifest](n: Int, gen: =>T)
, this will add an implicit parameter of type ClassManifest[T]
to your method, that is automatically passed to the call of testArray
and then further passed to the Array.fill
call. This is called a context bound
.