Thursday, 8 August 2013

Why is apply() not called ?

Why is apply() not called ?

When I run below code apply method is not being called :
object Tester2 {
def apply(){
println("apply")
}
def main(args: Array[String]) {
Tester2
}
}
But if I use Tester2() in main method instead of Tester the apply method
is then called
Why is () required in order for the apply method to be invoked ?

No comments:

Post a Comment