Skip to content

Coder Tutorial

Menu
  • Home
  • HTML
  • CSS
  • PHP
  • SQL
  • MySQL
  • JS
  • PL/SQL
  • Python
  • Java
  • Oracle
Home
Ruby
Ruby For Loop

Ruby For Loop

Ruby For Loop

The Ruby For Loop statement syntax and example.

For loop syntax

for value in expression do
	-- Ruby code 
end

For loop example

$x = 1

for $x in [1,2,3,4,5] do
   puts("The value of x = #$x" )
end

Output

The value of x = 1

The value of x = 2

The value of x = 3

The value of x = 4

The value of x = 5

Tutorials

  • Ruby Tutorial
  • Ruby Variables
  • Ruby Strings
  • Ruby Date and Time
  • Ruby Array
  • Ruby Hashes
  • Ruby Ranges
  • Ruby If-Elsif-Else
  • Ruby Case
  • Ruby For Loop
  • Ruby While Loop
  • Ruby Until Loop
  • Ruby Each Loop
  • Ruby Next Statement
  • Ruby Break Statement
  • Ruby Return statement
  • Ruby Methods
  • Ruby Blocks
  • Ruby Exceptions

Recent Posts

  • Java Polymorphism
  • Java Encapsulation
  • Java Abstraction
  • PostgreSQL ERROR: cannot begin/end transactions in PL/pgSQL
  • PostgreSQL Column must appear in the GROUP BY clause
  • PostgreSQL Column specified more than once
  • PostgreSQL Create database, Alter database examples
  • PostgreSQL Create schema syntax, Alter schema
  • PostgreSQL Create database user, alter and drop username
  • PostgreSQL Alter table name. Modify column name
Coder Tutorial Copyright © 2025. | Privacy Policy
Back to Top ↑