3 ms·
That should be logical AND, not logical OR, because if you go over the limit and the right side is False, the left side will always be True if the item is not f
by jjawssd 10y ago
That should be logical AND, not logical OR, because if you go over the limit and the right side is False, the left side will always be True if the item is not found, and True || False is still True, and the loop continues infinitely.
When you are over the iteration limit you want to trigger True && False which is False to break out of the loop where the right side False is the condition when pos > limit
Btw this is covered in Code Complete Second Edition by Microsoft Press on page 378-380
- pmontra 10y agoYou are right. I believed I didn't need a test for that. See what happens? :-)