include?(p1)
public
Returns true if str contains the given string or character.
"hello".include? "lo"
"hello".include? "ol"
"hello".include? ?h
Show source
/*
* call-seq:
* str.include? other_str => true or false
* str.include? fixnum => true or false
*
* Returns <code>true</code> if <i>str</i> contains the given string or
* character.
*
* "hello".include? "lo" #=> true
* "hello".include? "ol" #=> false
* "hello".include? ?h #=> true
*/
static VALUE
rb_str_include(str, arg)
VALUE str, arg;
{
long i;
if (FIXNUM_P(arg)) {
if (memchr(RSTRING(str)->ptr, FIX2INT(arg), RSTRING(str)->len))
return Qtrue;
return Qfalse;
}
StringValue(arg);
i = rb_str_index(str, arg, 0);
if (i == -1) return Qfalse;
return Qtrue;
}