私人範圍
範圍是私有的時,只能從當前類或當前類的其他例項訪問它。
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
}
}