Ruby | Range to_s() function Last Updated : 19 Mar, 2024 Improve Improve Like Article Like Save Share Report The to_s() is an inbuilt method in Ruby returns a string containing the given range. Syntax: range1.to_s() Parameters: The function accepts no parameter. Return Value: It returns a string containing the range. Example 1: # Ruby program for to_s() # method in Range # Initialize range range1 = (0..4) # Prints the string puts range1.to_s() Output: 0..4 Example 2: # Ruby program for to_s() # method in Range # Initialize range range1 = (7..9) # Prints the string puts range1.to_s() Output: 7..9 Like Article Suggest improvement Previous Ruby | clear() function Next Ruby | Range new() function Share your thoughts in the comments Add Your Comment Please Login to comment...