Thursday, February 21, 2013

Loops Introduction


Ah, loops. A classic topic. If you don't already, you'll learn to love them. Think of a loop as your friend who doesn't mind repeat tasks. Your parents tell you to wash every fork used at dinner one at a time by hand, and just before your next four hours are consumed with dish soap, your friend steps in to help you and take care of that job for you.

Ok, loops won't do that. But they will do monotonous tasks for you without complaining at all. Loops are so often useful, all I can really do is give a few examples and let you see the benefit yourself.

Let's say you having an array with 500 strings in it. You need to make sure they all end in a period. You'd be sitting at your computer all night if it wasn't for loops.

Voila! You've just done your checking.

Perhaps you have an array and you aren't sure how many items have been populated. There's a loop for that.


Why should you care?

Because loops are awesome.

But seriously....loops are awesome. As usual, my examples here are a little trivial, but loops are a crucial aspect of being a good programmer. They let you control, validate, and manipulate large volumes of data. Once you understand them, you'll be surprised you could ever live without them.

No comments:

Post a Comment