Home arrow Ruby-on-Rails arrow Ruby Loops

Ruby Loops

After last week, I know you've been eagerly waiting for this, the fifth article in my Ruby on Rails series. This one will give you an in-depth look at Loops, Methods, and Blocks. Well maybe Blocks. You'll have to see. So without a bunch of unnecessary yammering, let's get to it.

Author Info:
By: James Payne
Rating: 5 stars5 stars5 stars5 stars5 stars / 16
October 22, 2007
  1. · Ruby Loops
  2. · The While Loop
  3. · Stop that Loop!
  4. · Reach Out and Touch Someone
  5. · Scope

print this article

Ruby Loops
(Page 1 of 5 )

In the words of the immortal bard, Mr. T: Enough jibba-jabba!


One day, deep in the forest primeval, I saw a bird with an enormous, striped beak and improbably large eyes. It yelled at me, asserting that I should follow it, as its olfactory sense always knew. What it knew, the bird would not say. But I was curious, so I followed it further into the murks of the forest, unafraid of head hunters, giant spiders, and herculean gorillas. At long last, spent and sweaty, we reached our destination.

A log, with a stupid bowl of sugary rainbow-colored cereal resting atop it. Stupid bird.

Anyway, those loops, while delicious and questionably nutritious, are not the kind of loops we were looking for -- or, more precisely, they're not the kind of loops Ruby uses.

Loops are an exceptional tool for programmers. Loops allow you to repeat the same task over and over again on a set of data. Of course if you aren't careful, you could make the computer run the same set of data infinitely; but we're not amateurs here, so we don't have to worry about that.

You've probably encountered another version of a loop in real life. Like me, on garbage nights, your girlfriend probably gets caught up in one of these loops. In my case, it's as if someone has programmed her to repeatedly remind me that the garbage needs to go to the curb. It's a good thing someone embedded this program in her brain too, because if she didn't loop it over and over, several things would happen: 1) I would still have a full head of lustrous hair, 2) My hands would stop shaking and 3) I would, inevitably, forget to take out the trash.

blog comments powered by Disqus

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials