Quote:
Originally Posted by GuskiS
Is returning in loop a good way? I have always broke it, then return.
|
If you refer to this
It's invalid, the compiler will throw a warning, because you have no reason to do it.
I don't see a problem in using "return" in a loop, if you don't want to continue with the function, if the loop reach something, return is just fine. This all depends on what you need.
Code:
loop
{
if( iterator % 3 == 0 )
{
break
}
}
//some code here
//end of public
By using break the block of code outside the loop will still execute. If you will use return it won't.
__________________