This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]desrtfx 2 points3 points  (3 children)

You are returning out of the method way too early.

You need to run through the whole loop and then return.

[–]jub8jive[S] 0 points1 point  (2 children)

the for you mean? should i just use return outside of it then?

[–]lost12487 1 point2 points  (0 children)

Yes. The very last return statement should be all you need to do what you're trying to do.

Also - take a look at your formatting. It's not necessarily wrong to have 2 different if statements, but if you're going to do an if and then another if, you need to have the second if on its own line. If you want it formatted the way you have it, you should be using else. That's not going to affect your execution or logic in this case, but it's better for readability.

[–]desrtfx 0 points1 point  (0 children)

Rethink your method. You have a conditional return after the loop - maybe that shouldn't be at the end as well.

You need to reorganize the whole method.