Ruby-on-Rails
  Home arrow Ruby-on-Rails arrow Ruby Loops
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
RUBY-ON-RAILS

Ruby Loops
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2007-10-22

    Table of Contents:
  • Ruby Loops
  • The While Loop
  • Stop that Loop!
  • Reach Out and Touch Someone
  • Scope

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    Ruby Loops


    (Page 1 of 5 )

    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.

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

    Loops

    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.

    More Ruby-on-Rails Articles
    More By James Payne


       · The series on Ruby continues! In this episode we discuss loops, including the While,...
     

    RUBY-ON-RAILS ARTICLES

    - Ruby On Rails: Making Your First Dynamic Site
    - Ruby on Rails: Beginning Rails
    - Ruby: Modules, Mixins, Fixins, and Rails
    - Controlling Information Access with the Rail...
    - URLs, Filters and the Rails Action Controller
    - Flash and the Rails Action Controller
    - Rails Action Controller
    - Dropping and Sorting with AJAX and script.ac...
    - Drag and Drop with script.aculo.us and Rails
    - Introducing script.aculo.us
    - Ruby Classes and Objects
    - Ruby Loops
    - Ruby Conditionals
    - Ruby Operators and Arrays
    - Ruby for the Newbie


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway