Following is a example.
'A'.compare('a', case_insensitive: true)
Following is a example.
'A'.compare('a', case_insensitive: true)
You can do:
'A'.downcase <=> 'a'.downcase
The reason why case insensitive comparison exists for String is because otherwise if you call downcase
on it we need to create a new string and memory, and that’s not efficient.
But when calling downcase
on a char there’s never a need to allocate memory.
So I don’t think there’s a need to add case insensitive comparison to Char.