In Scala, given a generic type T, how to retrieve the list of field names and the field types? For example, if I have the case class:
case class Person(name: String, age: Int, gender: Boolean)
And the generic function:
def getFieldNamesAndTypes[T](): Seq[(String, String)]
I would like to be able to retrieve a sequence (in order that the fields appear) of the fields (name, type):
val fieldNamesAndTypes = getFieldNamesAndTypes[Person]()
Aucun commentaire:
Enregistrer un commentaire