📜  红宝石 |范围 == 方法

📅  最后修改于: 2022-05-13 01:55:17.199000             🧑  作者: Mango

红宝石 |范围 == 方法

==是 Ruby 中的一个内置方法,如果两个给定范围相等,则返回布尔值 true,否则返回 false。

示例 1

Ruby
# Ruby program for == method in Range
 
# Initialize range
range1 = (0..10)
range2 = (0..10)
 
# Prints the boolean value
puts range1 == range2


Ruby
# Ruby program for == method in Range
 
# Initialize range
range1 = (10..20)
range2 = (0..10)
 
# Prints the boolean value
puts range1 == range2


输出

true

示例 2

红宝石

# Ruby program for == method in Range
 
# Initialize range
range1 = (10..20)
range2 = (0..10)
 
# Prints the boolean value
puts range1 == range2

输出

false