【问题标题】:why is new Directory() allowed in Dart?为什么 Dart 中允许使用 new Directory()?
【发布时间】:2020-05-08 22:20:17
【问题描述】:

为什么 Dart 中允许使用 new Directory("myDir")?它的定义说Directory 是一个抽象类。

在它的语言之旅中,它说抽象类不能被实例化。

【问题讨论】:

    标签: class dart instantiation


    【解决方案1】:

    虽然Directory 确实是一个抽象类,但它提供了一个factory constructor,它返回一个具体实现类的实例。

    【讨论】:

      猜你喜欢
      • 2016-01-30
      • 1970-01-01
      • 1970-01-01
      • 2017-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-10
      • 2019-03-14
      相关资源
      最近更新 更多