[ruby-core:77377] [Ruby trunk Feature#12786] String#casecmp?
From:
duerst@...
Date:
2016-09-24 02:53:23 UTC
List:
ruby-core #77377
Issue #12786 has been updated by Martin D端rst.
Can you describe exactly what String#casecmp? method would do? Does it only compare for equality (after case folding)?
This proposal is interesting, because String#upcase/downcase/capitalize/swapcase now work for all of Unicode. But String#casecmp doesn't, because it would be a lot of additional work (and would depend on natural language) as to which string is larger or smaller.
But that doesn't apply to String#casecmp?, so it could be made to work rather easily with all of Unicode. Essentially, the implementation would be something like
````ruby
class String
def casecomp? (other)
downcase(:fold) == other.downcase(:fold)
end
end
````
----------------------------------------
Feature #12786: String#casecmp?
https://bugs.ruby-lang.org/issues/12786#change-60623
* Author: Ryan Ringler
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
Description
I would find String#casecmp? convenience method handy. I don't believe I've ever called String#casecmp without chaining #zero? to the result.
```ruby
'abc'.casecmp?('ABC') #=> true
'abc'.casecmp?('DEF') #=> false
```
---Files--------------------------------
string_casecmp_.patch (4.89 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>