2. Logic and Loops
Overview
In this chapter, we'll use branching logic and loops to demonstrate how logic can be controlled and selectively run. With these tools, you'll have control of what you do and don't want to run based on the values of variables.
By the end of this chapter, you will be able to implement branching logic using if, else, and else if; use switch statements to simplify complex branching logic; create looping logic using a for loop; loop over complex data collections using range; and use continue and break to take control of the flow of loops.
Introduction
In the previous chapter, we looked at variables and values and how we can temporarily store data in a variable and make changes to that data. We're now going to look ...
Get The Go Workshop now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.