Created
November 19, 2021 07:57
-
-
Save doyle-flutter/0c92e151f3215d411703bab6c0740331 to your computer and use it in GitHub Desktop.
[입문] 반복문 사용에 가장 많이하는 실수
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main(){ | |
| // 👿 반복문 사용에 가장 많이하는 실수 | |
| List<int> l = List<int>.generate(10, (int i) => i); | |
| // 📌 1. Error | |
| // for(int i in l){ | |
| // if(i == 3){ | |
| // l.add(123); | |
| // } | |
| // } | |
| // 📌 2. Error | |
| // l.forEach((int i){ | |
| // if(i == 3){ | |
| // l.add(i); // l.remove(i); | |
| // } | |
| // }); | |
| // 📌 3. Error | |
| // List<int> l2 = l.map<int>((int i){ | |
| // if(i == 3){ | |
| // // l.add(i); // l.remove(i); | |
| // } | |
| // return i; | |
| // }).toList(); | |
| // 🍭 | |
| // for(int i = 0; i < l.length; i++){ | |
| // if(i == 3){ | |
| // l.add(123); | |
| // } | |
| // } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment