红宝石 |范围 === 方法
===是 Ruby 中的一个内置方法,如果给定对象在范围内,则返回布尔值 true,否则返回 false。
Syntax: range1 === obj
Parameters: The function accepts no parameter
Return Value: It returns boolean value true if the given object lies in the range, else it returns false.
示例 1 :
# Ruby program for === method in Range
# Initialize range
range1 = (0..10)
# Prints the Boolean value
puts range1 === 8
输出:
true
示例 2 :
# Ruby program for === method in Range
# Initialize range
range1 = (0..20)
# Prints the boolean value
puts range1 === 82
输出:
false