I don’t understand why the compiler cannot understand the case instruction mapping on tuple when i try to use with generics Array[T].
class Variable[T](val p: Prototype[T], val value: T)
class Prototype[T](val name: String)(implicit m: Manifest[T])
// Columns to variable converter
implicit def columns2Variables[T](columns:Array[(String,Array[T])]): Iterable[Variable[Array[T]]] = {
columns.map{
case(name,value) =>
new Variable[Array[T]](new Prototype[Array[T]](name), value)
}.toIterable
}
Error say :
error: constructor cannot be instantiated to expected type;
found : (T1, T2)
required: fr.geocite.simExplorator.data.Variable[Array[T]]
case(name,value) =>
I’m also not sure about the wording of the error, but first of all, you will need the manifest for
Tbecause it is required for constructingnew Prototype[Array[T]](the array manifest can be automatically generated if a manifest for its type parameter is in scope).Is there any reason you absolutely need arrays? They come with the irregularity of Java’s type system, they are mutable, and they offer very little advantage over for example
Vector. Lastly, and that’s probably why carry around the manifests, unlike arrays standard collections do not require manifests for construction.