Method: String#include?

Defined in:
string.c

#include?(other_string) ⇒ Boolean

Returns true if self contains other_string, false otherwise:

s = 'foo'
s.include?('f')    # => true
s.include?('fo')   # => true
s.include?('food') # => false

Returns:

  • (Boolean)


6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
# File 'string.c', line 6971

VALUE
rb_str_include(VALUE str, VALUE arg)
{
    long i;

    StringValue(arg);
    i = rb_str_index(str, arg, 0);

    return RBOOL(i != -1);
}