首页 > 解决方案 > 获取 Scala 类对象中具有值的所有公共字段

问题描述

如何从 Scala 类的对象中获取所有公共字段(包括继承的)及其值?

这个:

class A(val a: String)

class B(val b: String) extends A("a")

val b = new B("b")

b.getClass.getFields

返回空列表。

标签: scalareflection

解决方案


推荐阅读