Open In App

Ruby | Range entries() function

Last Updated : 12 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report
The entries() is an inbuilt method in Ruby returns an array containing all elements of the given range.
Syntax: range1.entries() Parameters: The function accepts no parameter. Return Value: It returns an array containing all elements of the given range.
Example 1: Ruby
# Ruby program for entries()
# method in Range 

# Initialize range 
range1 = (0..10)

# Stores in array 
arr = range1.entries()

# Prints elements
puts arr
Output:
0
1
2
3
4
5
6
7
8
9
10
Example 2: Ruby
# Ruby program for entries()
# method in Range 

# Initialize range 
range1 = (2..4)

# Stores in array 
arr = range1.entries()

# Prints elements
puts arr
Output:
2
3
4

Similar Reads