Open In App

Ruby | Range inspect() function

Improve
Improve
Like Article
Like
Save
Share
Report

The inspect() is an inbuilt method in Ruby returns the range object in a printable form

Syntax: range1.inspect()

Parameters: The function accepts no parameter

Return Value: It returns the range object in a printable form

Example 1:




# Ruby program for inspect()
# method in Range 
  
# Initialize range 
range1 = (0..10)
  
# Prints the printable form 
puts range1.inspect()


Output:

0..10

Example 2:




# Ruby program for inspect()
# method in Range 
  
# Initialize range 
range1 = (12..14)
  
# Prints the printable form 
puts range1.inspect()


Output:

12..14

Last Updated : 19 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads