instance method
Symbol#casecmp?
(untyped object) -> bool?
casecmp?(object) → true, false, or nil
string.c
View on GitHub ↗
static VALUE
sym_casecmp_p(VALUE sym, VALUE other)
{
if (!SYMBOL_P(other)) {
return Qnil;
}
return str_casecmp_p(rb_sym2str(sym), rb_sym2str(other));
}
Returns true if self and object are equal after Unicode case folding, otherwise false:
Example
lower = :abc upper = :ABC upper.casecmp?(lower) # => true lower.casecmp?(lower) # => true lower.casecmp?(upper) # => true
Returns nil if self and object have incompatible encodings, or if object is not a symbol:
Example
sym = 'äöü'.encode("ISO-8859-1").to_sym other_sym = 'ÄÖÜ' sym.casecmp?(other_sym) # => nil :foo.casecmp?(2) # => nil
Unlike Symbol#casecmp, works for characters outside of ‘A’..‘Z’ and ‘a’..‘z’:
Example
lower = :äöü upper = :ÄÖÜ upper.casecmp?(lower) # => true lower.casecmp?(lower) # => true lower.casecmp?(upper) # => true
Related: Symbol#casecmp, String#casecmp?.