Ruby | Range to_s() function
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:
range1 = ( 0 .. 4 )
puts range1.to_s()
|
Output:
0..4
Example 2:
range1 = ( 7 .. 9 )
puts range1.to_s()
|
Output:
7..9
Last Updated :
19 Mar, 2024
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...