[英]ES6 js “with” keyword
在深度互联网中,我遇到类似class A extends B with C { ... }
结构, class A extends B with C { ... }
,我现在没有链接,在扩展抽象类时它就像类的宏。
这是标准的吗? (我用Google搜索,发现只有老with
被去除,现在,铬直列控制台抛出错误)
不,这不是ECMAScript 6 Classes标准的一部分。 请参阅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 Artist
这不标准。 从附件A.4 - 函数和类 ,语法是
[Yield, Default] :
class [?Yield] [?Yield]
[+Default] class [?Yield]
[Yield] :
class [?Yield]opt [?Yield]
[Yield] :
[?Yield]opt { [?Yield]opt }
[Yield] :
extends [?Yield]
is the part which includes both the optional extends something
and the class body. 所以是包含可选的extends something
和class体的部分。 , without any with
in there. 这something
必须是没有任何with
在那里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.