I have a pretty straightforward example, but in the same time it is confused. It is shown below:
abstract class AbstractClass[A] {
def function1(elem: A)(f: A => A): AbstractClass[A]
object AbstarctClass {
def function2(f: A => A) = new AbstractClass[A] {
override def function1(elem: A)(f: A => A): AbstractClass[A] =
// some code
}
}
}
Is there way to differ two functions, that receives function1 and function2, in scope of function1? I know, we can call them in different way and they will be used properly, but I'm interested how can we differentiate them in this case?
Update parent class declaration:
abstract class AbstractClass[A] { parent =>
// ...
}
Then
parent.function1(..)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.