use*_*116 7 scala field public
在java中,我有一个这样的类:
public class MyClass extends Properties {
public StringProperty prop1 = new StringProperty(this, "default value for prop1");
public StringProperty prop2 = new StringProperty(this, "prop2 default val");
}//MyClass
Run Code Online (Sandbox Code Playgroud)
父类"Properties"使用反射来查找自身中的所有公共字段,并根据需要使用值填充变量.
我如何在scala中扩展属性?使用var prop1:StringProperty ...不起作用,我假设由于scala如何将私有字段转换为... set ...类型方法.