Ada*_*ung 15
这与结构类型密切相关,但与任何匿名对象实例密切相关,即
new { def print = ("hello world") }.print
Run Code Online (Sandbox Code Playgroud)
将使用反射.
http://scala-programming-language.1934581.n4.nabble.com/Structural-types-reflection-td3071599.html
Ken*_*oom 10
枚举使用反射来查找nameOf函数枚举的所有可能值.(参见Enumeration.scala中的populateNameMap方法).这是第一次调用特定类型时完成的一次.nameOfEnumeration
结构类型中的方法调用取决于反射:
type T = { def startsWith(x:String):Boolean }
def doSomethingWith(x:T) = x.startsWith("abc")
doSomethingWith("abcdef")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
927 次 |
| 最近记录: |