Issue #10177 has been updated by First Last.


in the interest of maximizing the English readability and sensibility (self documentability) of predicates, it is key? that should be deprecated.

when you have an instance method predicate in the form receiver.noun? this reads in English as "Receiver, are you a <noun>?", when in the form receiver.adjective?, "Receiver, are you <adjective>?"  There is simply not enough information in a single noun or adjective to ask anything else.

So hash.key? reads, "hash, are you a key?"

If you want to ask a question of the receiver other than "Are you a <noun>?" or "Are you <adjective>?" the predicate has to be modified to reflect the question.

has_key? is perfect, it has enough information to be self documenting, it also implies that grammatical object of the question (the key) needs to be passed in.

----------------------------------------
Feature #10177: Hash#has_key? and Hash#has_value? should be deprecated
https://bugs.ruby-lang.org/issues/10177#change-48703

* Author: gogo tanaka
* Status: Open
* Priority: Normal
* Assignee: 
* Category: lib
* Target version: 
----------------------------------------
I referred to this Matz's remark.

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/43765

And I agree with him, I supposed `Hash#has_key?` should be preferred over `Hash#key?`, 

so I replaced all of `Hash#has_key?` and `Hash#has_value?` in `lib/*` with `Hash#key?` and `Hash#value?` 

---Files--------------------------------
Replace_Hash#has_something.PATCH (20.4 KB)


-- 
https://bugs.ruby-lang.org/