上面类的访问方法

xyz*_*xyz 2 scala

如何在B类中使用A类的isEmpty?

Class A{
  def isEmpty = ...

  Class B{
    def isEmpty = ...
  }

}
Run Code Online (Sandbox Code Playgroud)

Jea*_*let 7

试试这个:

class A {
  outer =>

  def isEmpty = ...
  class B {
    def isEmpty = outer.isEmpty
  }
}
Run Code Online (Sandbox Code Playgroud)

或者:

class A {
  def isEmpty = ...
  class B {
    def isEmpty = A.this.isEmpty
  }
}
Run Code Online (Sandbox Code Playgroud)