Skip to content

Coder Tutorial

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

Ruby Ranges

Ruby Ranges

The Ruby range represents an interval of values.
The syntax of Ruby range allow you to include or exclude its ending value.

Ranges syntax

(1..10)  
(1...10) 

Ranges example

r1 = (1..5).to_a
r2 = (1...5).to_a
r3 = (1..5).to_a.reverse   

puts "#{r1}" 
puts "#{r2}" 
puts "#{r3}" 

Output

[1, 2, 3, 4, 5]

[1, 2, 3, 4]

[5, 4, 3, 2, 1]

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 ↑