It turns out that you could avoid the #downcase with string.count("xX") == string.count("oO")
#downcase
string.count("xX") == string.count("oO")
I don't know whether the performance would be significantly different, though it would avoid creating a couple of extra string instances.
There are some other interesting variations for #count, such as using it to count lower case letters with "abGvf".count("a-z")
#count
"abGvf".count("a-z")
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It turns out that you could avoid the
#downcase
withstring.count("xX") == string.count("oO")
I don't know whether the performance would be significantly different, though it would avoid creating a couple of extra string instances.
There are some other interesting variations for
#count
, such as using it to count lower case letters with"abGvf".count("a-z")