for循环
```java
List myList=[1,2,3,4];
List newList = newList();
for (var I= 0 ;I < myList.length ; i++) { newList.add(myList[I] * 2) ; }
```
for..in..
```python
List myList=[1,2,3,4];
List newList = newList();
for(var I in myList){ newList.add( myList[I] * 2 );}
```
forEach
```python
ListmyList = [1,2,3,4];myList.forEach((v){
print(v);
});
```
map
```python
var newList = myList.map((v){
return v *2;
});
print(newList.toList());
```
where
返回满足条件的值
```python
List myList2 = [1,2,3,4,5,6,7];
var newList2 = myList.where((v){
return v > 5;
});
print(newList2.toList()); // 6,7
```
any
只要有一个满足条件就返回true
```python
var f = myList.any((v){
return v > 5;
});
print(f); // true
```
every
条件都满足了才能返回true 否则返回false
```python
var f2 = myList.every((v){
returnv > 5;
});
print(f2); // fasle
```
网友评论