红宝石 |字符串 == 方法
==()是 Ruby 中的 String 类方法,用于检查 str==obj 是否。
Syntax: str == obj
Parameters: Here, str is the given string and obj is the object to be compared.
Returns: True or False based on the equality of the two strings.
示例 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