From: duerst@... Date: 2016-11-29T10:35:28+00:00 Subject: [ruby-core:78414] [Ruby trunk Feature#12786] String#casecmp? Issue #12786 has been updated by Martin D��rst. Ryan Ringler wrote: > I see the changeset implements the new method by calling `String#downcase` on both strings and compares the results for equality. Yes, this is as proposed at https://bugs.ruby-lang.org/issues/12786#note-1. > While this does allow unicode support in advance of `String#casecmp`, it sacrifices the performance of character-by-character comparison that `#casecmp` provides. Yes, I realized this as I implemented it. For the moment, my take is "better slow than fast and wrong". > It's also going to lead to some inconsistent behavior: > > ``` > '������'.casecmp('������').zero? # false > '������'.casecmp?('������') # true > ``` Yes. I added some additional explanations to the documentation today to make this clearer. > I hope this was considered, and perhaps when `String#casecmp` provides better support for unicode we can update `#casecmp?` to use it. It would definitely be great to implement Unicode sorting, and in that case, we will make sure that casecmp and casecmp? are consistent again. But that will be a LOT of work. Also, please note that implementing Unicode sorting will make casecmp slower, too. ---------------------------------------- Feature #12786: String#casecmp? https://bugs.ruby-lang.org/issues/12786#change-61787 * Author: Ryan Ringler * Status: Closed * Priority: Normal * Assignee: Martin D��rst ---------------------------------------- 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.97 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: