How can I look up the value of an object\'s property dynamically by name in Scala 2.10.x?
E.g. Given the class (it can\'t be a case class):
class Row(val
You could also use the bean functionality from java/scala:
import scala.beans.BeanProperty
import java.beans.Introspector
object BeanEx extends App {
case class Stuff(@BeanProperty val i: Int, @BeanProperty val j: String)
val info = Introspector.getBeanInfo(classOf[Stuff])
val instance = Stuff(10, "Hello")
info.getPropertyDescriptors.map { p =>
println(p.getReadMethod.invoke(instance))
}
}