静态类型语言中的多边界方法?
multi bounded methods in a statically typed language?
抱歉,标题有点错误。因为我在想方法绑定的问题,所以就出现了这个问题。
带有一些伪代码的示例..
interface A
interface B
val z: A & B = [object of a class that implements A and B];
他们有支持此功能的静态语言吗?
-> 解决对两种类型 z 的引用。
还是我逻辑有问题,不可能?
你可以在 scala 中使用 traits:
trait A
trait B
class Z extends A with B
val z: A with B = new Z
抱歉,标题有点错误。因为我在想方法绑定的问题,所以就出现了这个问题。 带有一些伪代码的示例..
interface A
interface B
val z: A & B = [object of a class that implements A and B];
他们有支持此功能的静态语言吗?
-> 解决对两种类型 z 的引用。
还是我逻辑有问题,不可能?
你可以在 scala 中使用 traits:
trait A
trait B
class Z extends A with B
val z: A with B = new Z