Skip to content
instance method

String#casecmp?

(::string other) -> bool
(untyped) -> bool?
casecmp?(other_string) → true, false, or nil

Returns true if self and other_string are equal after Unicode case folding, false if unequal, nil if incomparable.

See Case Mapping.

Examples:

Example
'foo'.casecmp?('goo')  # => false
'goo'.casecmp?('foo')  # => false
'foo'.casecmp?('food') # => false
'food'.casecmp?('foo') # => false
'FOO'.casecmp?('foo')  # => true
'foo'.casecmp?('FOO')  # => true
'foo'.casecmp?(1)      # => nil

Related: see Comparing.

See also #casecmp #center #capitalize! #chars also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0