Copyright © 2022-2025 aizws.net · 网站版本: v1.2.6·内部版本: v1.25.2·
页面加载耗时 0.00 毫秒·物理内存 129.7MB ·虚拟内存 1372.6MB
欢迎来到 AI 中文社区(简称 AI 中文社),这里是学习交流 AI 人工智能技术的中文社区。 为了更好的体验,本站推荐使用 Chrome 浏览器。
List只是一组有序的对象。该 dart:core 库提供的列表类,使创建和列表的操作。
Dart中的列表可归类为
下面给出了一个Dart实现List的例子。
void main() {
List logTypes = new List();
logTypes.add("WARNING");
logTypes.add("ERROR");
logTypes.add("INFO");
// iterating across list
for(String type in logTypes){
print(type);
}
// printing size of the list
print(logTypes.length);
logTypes.remove("WARNING");
print("size after removing.");
print(logTypes.length);
}
上述代码的 输出:
WARNING ERROR INFO 3 size after removing. 2
Set表示对象的集合,其中每个对象只能出现一次,dart:core库提供了Set类。语法Identifier = new Set()或者Identifier = new Set.from(Iterable)其中, It ...