Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Ruby | Range entries() function

  • Last Updated : 18 Dec, 2019

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 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 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
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!