有没有办法从Scala中的Anonymous类扩展另一个类?我的意思是
abstract class Salutation {
def saybye(): String = "Bye"
}
class anotherClass() {
def dummyFunction() = {
val hello = new {
def sayhello(): String = "hello"
} extends Salutation
val hi = hello.sayhello //hi value is "Hello"
val bye = hello.saybye //bye value is "bye"
}
}
Run Code Online (Sandbox Code Playgroud) scala ×1