How can I make a field that has a public getter but the setter is private, in Scala?
EDIT: too bad there is no one-liner way to do this like there is in Groovy. Those solutions are all pretty clunky looking.
class Foo {
private var _value: Int = 0
def value = _value
}
class ExplicitProperty {
private[this] var s: Int = _
def size = s
private def size_=(x: Int) {
s = x
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With