Issue #10177 has been updated by First Last.


Tsuyoshi Sawada wrote:
> I don't understand how `has_key?` is better

I already explained it, all I can do is restate it.

When the predicate consists of a just single noun or adjective, there is only enough information in it to ask one type of question (Are you?).  

Are you a {noun}? (e.g. proc.lambda? => "proc, are you a lambda?")
Are you an {adjective}? (e.g. array.empty? => "array, are you empty?")

It can't mean anything whatsoever (have you?, should you?, countless other inquiries), because then the predicate name would be inscrutable, which is the opposite of the purpose of naming.

If you want to ask something other than "Are you?" there needs to be more information in the method name (e.g. has_key?)

That the conjugation can be off is nothing, next to not knowing what question is being asked.

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

* 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/