📜  红宝石 |字符串 === 方法

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

红宝石 |字符串 === 方法

===()是 Ruby 中的 String 类方法,用于检查 str==obj 是否。该方法类似于字符串类的 == 方法。

示例 1:

#ruby 2.3.1 
     
# Ruby program to demonstrate
# the === method
     
# Taking a string and
# using the method
puts "Ruby" === "Ruby"
puts "Hello" === "Hell"

输出:

true
false

示例 2:

#ruby 2.3.1 
     
# Ruby program to demonstrate
# the === method
     
# Taking a string and
# using the method
puts "ayucdef" === "ayucdefg"
puts "Ruby" === 77

输出:

false
false