且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如果我们在构造函数中定义了默认值,如何使用Scala反射调用默认构造函数

更新时间:2023-10-10 07:51:45

只有一个构造函数.默认值保留在人"随行对象中.呼叫 new Person(年龄= 10)会变成类似 new Person(Person.< init> $ default $ 1(),10).

There is only one constructor. The default values are kept in the Person companion object. A call new Person(age = 10) is turned into something like new Person(Person.<init>$default$1(), 10).