How can I express in Scala class configuration option?

时间:2015-09-01 22:09:52

标签: scala

In the title I provided use-case for the following behavior: the field should be publicly mutable and immutable for the class's own methods. Consider also that I essentially want single line per field, because the number of fields may be great. Also I want to have no-arg constructor.

1 个答案:

答案 0 :(得分:3)

我能想到的最接近你想要的就是拥有一个只具有存取方法的特征,以及一个允许突变的实现类。将类类型传递给您需要能够更改值的位置,但仅在值不可更改的任何位置引用它作为特征。