包裝保護範圍
包受保護的作用域允許僅從特定包中的任何子類訪問該值。
package com.example {
class FooClass {
protected[example] val x = "foo"
}
class ClassB extends FooClass {
val y = x // It's in the protected scope, will compile
}
}
package com {
class BarClass extends com.example.FooClass {
val y = x // <- Outside the protected scope, will not compile
}
}