mercredi 11 février 2015

How can I reflect the type of a collection in Scala?

I'm trying to reflect on the parameterized type of a collection, for example:



val model = List(1)
val classSymbol = currentMirror.classSymbol(model.getClass )
val typeParamArgs = classSymbol.typeParams
println(typeParamArgs)


Unfortunately this only gives me 'B' as the type, not Int as I'd hoped. How can I reflect to know that this is a List[Int]? Can I get this statically (preferred)?






Aucun commentaire:

Enregistrer un commentaire