As far as I can tell, this is the correct way to do case-insensitive string comparison in Ruby:
if string1.casecmp(string2) == 0 # strings match, ignoring case end
That’s so ugly, it almost looks like Java. Actually, it’s worse than Java, which has String#equalsIgnoreCase
.
4 replies on “String#casecmp”
We need to do that for Mojo too as .NET creates the hex digest in upper case =/
Yeah yeah, already done :-) – that’s where I found it.
This looks better to me:
string1.downcase == string2.downcase
You could use regular expressions:
string1 =~ /^string2$/i