Changes

Jump to: navigation, search

Ruby While and Until Loops

883 bytes added, 15:49, 26 November 2007
New page: If computers do one thing well it is performing tasks very quickly. One thing computers do even better is performing the same task over and over again until specific criteria are met (or e...
If computers do one thing well it is performing tasks very quickly. One thing computers do even better is performing the same task over and over again until specific criteria are met (or even infinitely if that is what is required). One this that computers are very bad at, however, is doing anything without being told to do it. Given these facts, it should come as no surprise that just about every programming language, Ruby included, provide mechanisms for instructing a computer system to repeat tasks.

In this chapter of [[Ruby Essentials]] we will look the structures provided by Ruby to allow loops to be built into applications.

== The Ruby While Loop ==

The Ruby ''while'' loop is designed to repeat a task until a particular expression is evaluated to be ''true''. The syntax of a ''while'' loop is as follows:

while ''expression'' do

... ''ruby code here'' ...

end

Navigation menu