Case insensitive comparison. (ASCII text only) : casecmp « String « Ruby






Case insensitive comparison. (ASCII text only)


# casecmp works like <=> and returns -1 for less, 0 for equal, +1 for greater
"world".casecmp("WORLD")  # => 0
"a".casecmp("B")          # => -1 (<=> returns 1 in this case)

 

Related examples in the same category

1.casecmp method