[Flutter, Dart 문법] List형 자료의 map 함수 관련 정리
void main() {
print("map fucntion train");
List<int> intList = [1,2,3,4];
List<int> newList = intList.map((value){
return value*2;
}).toList();
List<int> newList1 = intList.map<int>((value)=>value*3).toList();
print(intList);
print(newList);
print(newList1);
}
리스트 같이 이터러블에 있는 내장함수로 각 리스트의 항목들을 함수에 집어 넣어 다시 리스트로 만들때 사용합니다.
댓글