【发布时间】:2015-12-18 06:45:59
【问题描述】:
如果您需要一个完整的示例,代码在DartPad 上(请参阅最后的while 循环。)
我有一个循环,
Place place = places[0];
while (places.isNotEmpty) {
// Get a list of places within distance (we can travel to)
List reachables = place.getReachables();
// Get the closest reachable place
Place closest = place.getClosest(reachables);
// Remove the current place (ultimately should terminate the loop)
places.remove(place);
// Iterate
place = closest;
}
但它不会删除倒数第二行的place。即,places 列表的长度保持不变,使其成为无限循环。怎么了?
【问题讨论】:
-
你可以试试这个答案:) stackoverflow.com/a/70569910/12121284
标签: dart