Issue #12786 has been updated by Robert A. Heiler.


I think .eql? is not a good name because it chops away characters.

Imagine if we would have .sz or .sz? rather than .size. Or .lngth
rather than .length. :D

.casecmp? does chop away characters too but at least it is a bit
easier to read. Though the name could be .casecompare?() or 
.equal() or .case_equal? - actually the last one may be better.

You gave some more examples for names too:

    #case_equal?
    #case_insensitive_equal?
    #insensitive_equal?
    #iequal?

I think .iequal? is not good for the same reasons; right now I
like .case_equal? the most but perhaps there may be even better
names, who knows.

Anyway I guess the name can be decided at a later point too - guess
you have to see whether matz considers the described behaviour
useful to have for ruby. If so then I am sure the name can be
easily chosen. :)

(You need to keep in mind that, once implemented and available,
it will eventually be used in ruby scripts so it should "fit"
into ruby itself too.)

----------------------------------------
Feature #12786: String#casecmp?
https://bugs.ruby-lang.org/issues/12786#change-60723

* 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.97 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>