Scala Language Scope A private scope


When the scope is private, it can only be accessed from the current class or other instances of the current class.

package com.example {
  class FooClass {
    private val x = "foo"
    def aFoo(otherFoo: FooClass) {
      otherFoo.x // <- Accessing from another instance of the same class
  class BarClass {
    val f = new FooClass
    f.x // <- This will not compile