Ruby | Range entries() function
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 elementsputs 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 elementsputs arr |
Output:
2 3 4


