ruby 如何判斷字符串是否相等
3 回答

一只斗牛犬
TA貢獻1784條經驗 獲得超2個贊
String str1="abc";
String str2=“bcd";
if(str1.equals(str2)){
system.out.println("str1和str2相等”);
}
用的是equals()方法

瀟瀟雨雨
TA貢獻1833條經驗 獲得超4個贊
c中是strstr.
ruby 1.9.3中包含:
include? other_str → true or false click to toggle source
Returns true if str contains the given string or character.
"hello".include? "lo" #=> true
"hello".include? "ol" #=> false
"hello".include? ?h #=> true
- 3 回答
- 0 關注
- 592 瀏覽
添加回答
舉報
0/150
提交
取消