Can you guys help me to understand the usage of scala.runtime.AbstractFunction1 in scala. Why we need to override the apply method in it .
All classes in
scala.runtime are just implementation details used by code generated by the compiler. They shouldn't normally appear in user code.
There is one exception: if you need to call a method taking
* is the number of arguments) from Java, you should use a (usually anonymous) class extending
scala.runtime.AbstractFunction*, because the Java compiler doesn't know about Scala traits. But that isn't a "usage of scala.runtime.AbstractFunction1 in scala", so not relevant to this question.
You can also extend
scala.runtime.AbstractFunction* instead of
scala.Function* in Scala, but this has the same result (with slightly smaller generated code).