I wonder if it is possible to declare a public field in the Scala class. Scala usually generates a private field for the parameters valand varvariables of the body / constructor and getters / setters with appropriate visibility.
I would like to know if it is possible to declare a public Java class field in Scala rather than getter.
PS: Why would anyone need this? This can be useful, for example, for integration with field-based Java frameworks:
class MyTest extends JUnitSuite {
@Rule
val temporaryFolder = new TemporaryFilder()
// throws java.lang.Exception: The @Rule temporaryFolder must be public
}
source
share