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:
range1 = ( 0 .. 10 )
arr = range1.entries()
puts arr
|
Output:
0
1
2
3
4
5
6
7
8
9
10
Example 2:
range1 = ( 2 .. 4 )
arr = range1.entries()
puts arr
|
Output:
2
3
4
Share your thoughts in the comments
Please Login to comment...