在深入的互联网上,我遇到了像class A extends B with C { ... }这样的结构,我现在还没有链接,它就像在扩展抽象类时对类的宏。
这是标准的吗?(我谷歌了一下,只找到了现在删除的旧with,chrome内联控制台抛出了错误)
发布于 2016-09-05 19:29:48
不,这不是ECMAScript 6类标准的一部分。请参阅https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
在某些编程语言中使用with关键字来表示多重继承。
例如,Scala具有类可以用with关键字扩展的特性。
trait Drawable {
def draw() { }
}
trait Cowboy extends Drawable {
override def draw() { println("Bang!") }
}
trait Artist extends Drawable {
override def draw() { println("A pretty painting") }
}
class CowboyArtist extends Cowboy with Artisthttps://stackoverflow.com/questions/39336581
复制相似问题