Wondered if there is anyone here that can help me with this problem. I wish to search an array to avoid an item being entered if it has already been inserted. My code is:
The problem I seem to be having is that even when the item is found in the array it continues on and enters it in regardless. I have a feeling that there is something simple here that I am missing. So a sample output is:
Might I suggest you replace that by an ordinary boolean operation instead of by that comparison to false?
Why? Two reasons: first, what I posted there says "If not stopFound" which is more straightforward to understand compared to a comparison to false. Second, one of these days your finger will slip and you will type this:
Here you are assigning false to the stopFound variable and seeing what the value of the result is. The result will always be false, regardless of what the original value of stopFound was. And the compiler won't give you any hint of your problem.