Count to 10
We'll cover the following...
We’ve been using while
for looping for a while now. It’s taken a lot of self-restraint to not bring up for
loops yet. However, to properly understand them, you need to know about traits, enums, and Option
. Fortunately, now that we’ve covered these, we can finally use for
loops.
Anything you can do with a for
loop can also be done with a while
loop. However, as you’ll see shortly, the for
loop approach is usually much more pleasant to work with. You’re about to have a lot of fun simplifying some code. ...