有人可以解释一下这种 Dart 语法吗?这是在某处记录的吗?
abstract class FixedLengthListBase<E> =
ListBase<E> with FixedLengthListMixin<E>;
最佳答案
这是声明命名混合应用程序的语法。介绍in the "Mixins in Dart" article .
They are defined by a special form of class declaration that gives them a name and declares them equal to an application of a mixin to a superclass, given via a with clause.
这(几乎)与写作相同
abstract class FixedLengthListBase<E> extends
ListBase<E> with FixedLengthListMixin<E>{}
技术上的区别在于,在这种情况下
FixedLengthListBase
不是 mixin 应用程序本身,而是隐式的、未命名的 mixin 应用程序的抽象子类 ListBase<E> with FixedLengthListMixin<E>
关于Dartlang 语法用 mixin 扩展类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21552270/