In Scala, access modifiers can be emphasized by using qualifiers. The format is:
PRIVATE[X]
Or
PROTECTED[X]
The x here refers to a package, class, or single Instance object to which it belongs. If written as private[x], read "This member in addition to [...] The class in or [...] The classes in the package and their associated pairs are visible, and are private to all other classes.
This technique is useful in large projects that span a number of packages, allowing you to define something that is visible in several child packages of your project but is not always visible to customers outside the project.
Package bobsrocckets{
Package navigation{
Private[bobsrockets] class navigator{
protected[navigation] Def usestarchart () {}
class legofjourney{
Private[navigator] val distance = MB
Private[this] Var Speed = [
}
}
package launch{
Import navigation._
object vehicle{
Private[launch] Val Guide = new Navigator
}}}
In the above example, the Class navigator is labeled Private[bobsrockets] that means that the class is visible to all classes and objects contained in the Bobsrockets package.
For example, access to navigator from a vehicle object is allowed because the object vehicle is contained in the package launch, and launch is wrapped in bobsrockets, instead, All code outside the package Bobsrockets cannot access the Class navigator.
Original link: http://www.runoob.com/scala/scala-access-modifiers.html