标签:
这个又让我想起来了PYTHON当中的CALL和APPLY,,
真的是世界大同?
传说中的运行时反射呢?:)
package com.hengheng.scala
class UsageOfApply {
}
class ApplyTest{
def apply() = "This is in Class."
def test {
println("test")
}
}
object ApplyTest{
def apply() = new ApplyTest
def static {
println("I am a static method.")
}
}
object UsageOfApply extends App {
//ApplyTest.static
val a = ApplyTest()
println(a())
}
输出:
This is in Class.
标签:
原文地址:http://www.cnblogs.com/aguncn/p/4457354.html