What does this extra private [class] () mean in the scala class definition?

I am reading someone's elses code in Scala to learn the language a little, but I am puzzled as to what "privateutil" means. If I only saw [util], would I suspect that it was some kind of specific generic character? but does it have its own private modifier?

class RPGPluginProperties private[util]() extends Properties {

      

+3


source to share


1 answer


From http://www.scala-lang.org/files/archive/spec/2.11/05-classes-and-objects.html#private :

A private modifier can be qualified with a C identifier (for example, private [C]), which must denote a class or package, definition. Members marked with this modifier are, respectively, only accessible from code within package C, or only from code within class C and its companion module.



So, in this case, the private modifier makes the no-args constructor private to the util class / package.

To declare a class private for scope use, it would be the private [util] RPGPluginProperties class ...

+5


source







All Articles