Skip to content

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

instance method

String#eql?

eql?(object) → true or false

Returns true if object has the same length and content; as self; false otherwise:

Example
s = 'foo'
s.eql?('foo') # => true
s.eql?('food') # => false
s.eql?('FOO') # => false

Returns false if the two strings’ encodings are not compatible:

Example
"\u{e4 f6 fc}".encode("ISO-8859-1").eql?("\u{c4 d6 dc}") # => false
See also #end_with? #force_encoding #encoding #freeze also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0