Difference between protected and protected[this]
问题 I have the following code: class Base{ protected val alpha ="Alpha"; protected def sayHello = "Hello"; } class Derived extends Base{ val base = new Base; def hello = println(this.alpha +" "+this.sayHello) ; // def hello = println(base.alpha +" "+base.sayHello) ; // don't compile } object MyObj extends App{ val x=new Derived; x.hello; } In class Base , if I label protected with this , the code works as expected; if I don't label it with this , everything works as expected too. Are protected