红宝石 |范围检查()函数
inspect()是 Ruby 中的一个内置方法,以可打印的形式返回范围对象
Syntax: range1.inspect()
Parameters: The function accepts no parameter
Return Value: It returns the range object in a printable form
示例 1 :
# Ruby program for inspect()
# method in Range
# Initialize range
range1 = (0..10)
# Prints the printable form
puts range1.inspect()
输出:
0..10
示例 2 :
# Ruby program for inspect()
# method in Range
# Initialize range
range1 = (12..14)
# Prints the printable form
puts range1.inspect()
输出:
12..14