Last active
December 30, 2015 03:59
-
-
Save c4tachan/7772853 to your computer and use it in GitHub Desktop.
I recently saw this algorithm in a coworker's code, and I was confused by how he used the continue statement on line 18. It seems to me that the continue will only cause the inner foreach loop to continue and not the outer loop which is what I believe was the intention.
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
foo[5] a = { 1, 2, 3, 4, 5 }; //foo is a type | |
foo[3] b = { 1, 2, 3 }; | |
List<foo> unMatched = new List<foo>(); | |
foreach (foo c in a) | |
{ | |
bool wasMatched = false; | |
if(0 != c) | |
{ | |
foreach (foo d in b) | |
{ | |
if(c == d) | |
{ | |
wasMatched = true; | |
continue; | |
} | |
} | |
} | |
if(!wasMatched) | |
unMatched.Add(c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment