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 关注
- 567 浏览
添加回答
举报
0/150
提交
取消