Ruby | Range inspect() function Last Updated : 19 Mar, 2024 Comments Improve Suggest changes Like Article Like 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 # 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 # Ruby program for inspect() # method in Range # Initialize range range1 = (12..14) # Prints the printable form puts range1.inspect() Output: 12..14 Comment More infoAdvertise with us Next Article Ruby | Range inspect() function G gopaldave Follow Improve Article Tags : Ruby Ruby-Methods Ruby Range-class Similar Reads Ruby | Regexp inspect() function Regexp#inspect() is a Regexp class method which produces a formatted string-version of regular expression. Syntax: Regexp.inspect()Parameter: Regexp valuesReturn: a formatted string-version of regular expression Example #1 :  Ruby # Ruby code for Regexp.inspect() method # declaring Regexp value re 1 min read Ruby | Rational inspect() function The inspect() is an inbuilt function in Ruby returns the value as a string. Syntax: rat.inspect() Parameters: The function accepts no parameter Return Value: It returns the value as a string Example 1: Ruby # Ruby program for inspect() method # Initialize rational number rat1 = Rational(8, -6) # Pri 1 min read Ruby | Range new() function The new() is an inbuilt method in Ruby returns a new range of numbers. Syntax: range1.new(first, last) Parameters: The function accepts first and last which is the range that is to be created. Return Value: It returns the range of numbers. Example 1: Ruby # Ruby program for new() # method in Range # 1 min read Ruby | Range last() function The last() is an inbuilt method in Ruby returns an array of last X elements. If X is not mentioned, it returns the last element only. Syntax: range1.last(X) Parameters: The function accepts X which is the number of elements from the end. Return Value: It returns an array of last X elements. Example 1 min read Ruby | Range include?() function The include?() is an inbuilt method in Ruby returns a boolean value true if the given object lies within the given range, else it returns false. Syntax: range1.include?(obj) Parameters: The function accepts an object which is to be checked for. Return Value: It returns a boolean value true if the gi 1 min read Like