Is it possible to declare a public field in Scala

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
}
+4
source share
1 answer

This is in response to the PS, someone else sent the answer to the main question.

(, java) " " , "x" - , / , , . , /, - . scala , .

, !

-1

All Articles