58. Go - Break/Return

Break: break out of a loop, but continue the code below the loop

break is used to immediately terminate a for loop, a while loop or a switch statement. You can not break from an if block.


Return: break out of loop and out of method or whole block {} and return the value to caller.

return is used the terminate a method (and possibly return a value).


Comments

Popular posts from this blog

2. FreeCodeCamp - Dynamic Programming - Learn to Solve Algorithmic Problems & Coding Challenges

20. Data Analytics - Analyze Data to Answer Questions - Week 1

3. Algorithms - Selection Sort