Ruby While loop

This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.


Ruby while loop is similar in syntax with other interpreted scripting languages.

Ruby While Loop Syntax

while cond
   code to be executed
end

Ruby While Loop Example

ruby_variable = 0
while ruby_variable < 10
   ruby_variable++;
   puts ruby_variable
end





Post Comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.