我有一个MappedListIterable比我知道的要排序的
调用排序方法时,我得到
例外:NoSuchMethodError:类“MappedListIterable”没有实例方法“sort”。接收器:'MappedListIterable' 的实例尝试调用:sort(Closure: (dynamic, dynamic) => dynamic)
MappedListIterable在.map(f)上调用.map(f)后你会得到一个Iterable。
因此,您首先需要通过调用List从您那里获取 a 。MappedListIterable.toList()
var i = [1, 3, 2].map((i) => i + 1);
// i is a MappedListIterable
// you can not call i.sort(...)
var l = i.toList();
l.sort(); // works
Run Code Online (Sandbox Code Playgroud)
或者在一行中(代码高尔夫):
var i = [1, 3, 2].map((i) => i + 1).toList()..sort();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3818 次 |
| 最近记录: |