Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

String#include?

include? other_string → true or false

Returns true if self contains other_string, false otherwise:

Example
s = 'foo'
s.include?('f')    # => true
s.include?('fo')   # => true
s.include?('food') # => false
See also #hex #index #hash #initialize_copy also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0