mercredi 10 février 2016

Scala - How to get constructore fields values in reflection?

I'm pretty new to scala and struggling a bit with reflection.

Given the below class:

class Person (name: String) {
 .....
}

and the given instance:

val p = new Person ("MyName")

How can i retrieve the value "MyName" in reflection?

BTW - I tired with java reflection using getClass.getDeclaredFields(), but without luck...

Thanks!





Aucun commentaire:

Enregistrer un commentaire