method

casecmp

Importance_1
casecmp(p1) public

Case-insensitive version of Symbol#<=>. Currently, case-insensitivity only works on characters A-Z/a-z, not all of Unicode. This is different from Symbol#casecmp?.

:aBcDeF.casecmp(:abcde)     #=> 1
:aBcDeF.casecmp(:abcdef)    #=> 0
:aBcDeF.casecmp(:abcdefg)   #=> -1
:abcdef.casecmp(:ABCDEF)    #=> 0

nil is returned if the two symbols have incompatible encodings, or if other_symbol is not a symbol.

:foo.casecmp(2)   #=> nil
"\u{e4 f6 fc}".encode("ISO-8859-1").to_sym.casecmp(:"\u{c4 d6 dc}")   #=> nil
Show source
Register or log in to add new notes.