![](/img/trans.png)
[英]type 'ExpandIterable<InterfaceType, MethodElement>' is not a subtype of type 'Iterable<MethodElementImpl>' of 'iterable'
[英]Is there a modifiable Iterable type?
我需要一個可修改的集合,如List
或Set
作為參數傳遞。 使用Iterable
並不能保證此參數具有add
或remove
之類的方法。
示例方法:
void foo(Iterable bar) {
bar.add(); // The method 'add' isn't defined for the type 'Iterable'.
}
是否有用於(可修改)collections 的 class / 接口來保證這些方法? 如果不是,為什么?
沒有可修改的類型。 很早之前(在 Dart 1 之前)我們的層次結構中有一些其他類型,但我們決定避免包括它們,因為事情變得有點太復雜了。
我仍然希望我們發布一個沒有變異成員的List
接口。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.