Forum Discussion
ChrisAdams
3 years agoChampion Level 3
Hi,
Don't use for-each loop. Instead, use a 'traditional' for loop or while loop. I've wrote a second version in your other recent question to stop at the first instance of the string being found. That includes a for loop with a break statement.
I cheated slightly in the other solution by reading the contents of the entire file into a single string.
In your example above, you would need two break statements, one for each loop. You might find it easier and more readable to split into functions.
Related Content
- 5 years ago
- 3 years ago
Recent Discussions
- 19 hours ago
- 17 days ago