是否可以设置Dynamic
子类型,以便可以从空路径调用动态vals / defs,如果是,则如何调用?
插图:
import scala.language.dynamics
class Blah extends Dynamic {
def selectDynamic(name: String) = println(name)
}
new Blah {selectDynamic("foo")} //compiles
new Blah {this.foo} //also compiles
new Blah {foo} //error: not found: value foo