Home
Ruby
ActiveRecord
Array
CGI
Class
Collections
Database
Date
Design Patterns
Development
File Directory
GUI
Hash
Language Basics
Method
Network
Number
Rails
Range
Reflection
Statement
String
Threads
Time
Tk
Unit Test
Windows Platform
XML
Menu
with for « Range « Ruby
Ruby
Range
with for
1.
The for loop
2.
a for loop and an inclusive string range
3.
Drop the do. It isn't required, but you have to keep end:
4.
If you want to do the for loop on one line, you have to throw in the do
5.
An example of a for loop that prints out a times table (from 1 to 12) for the number 2
6.
With nested for loops, you can easily print out times tables from 1 to 12: