![](/img/trans.png)
[英]Scope of implicit functions in objects with the same name as the class in scala
[英]The way to differ two functions with the same name in available scope in Scala
我有一个非常简单的例子,但同时它也很混乱。 如下图所示:
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
}
}
}
有没有办法在功能1的scope中区分接收功能1和功能2的两个功能? 我知道,我们可以用不同的方式调用它们,它们会被正确使用,但我很感兴趣在这种情况下如何区分它们?
更新父 class 声明:
abstract class AbstractClass[A] { parent =>
// ...
}
然后
parent.function1(..)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.