私人范围
范围是私有的时,只能从当前类或当前类的其他实例访问它。
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
}
}