Scala Language Scope Object private scope


Example

The most restrictive scope is "object-private" scope, which only allows that value to be accessed from the same instance of the object.

class FooClass {
  private[this] val x = "foo"
  def aFoo(otherFoo: FooClass) = {
    otherFoo.x // <- This will not compile, accessing x outside the object instance
  }
}