Forum: Ruby-core Hash#has_key? and Hash#has_value? should be deprecated

A14d1bca90d7ebeda50dca99aab381b9?d=identicon&s=25 Markus H. (markus_h)
on 2014-08-29 20:37
(Received via mailing list)
Issue #10177 has been updated by Robert A. Heiler.


I liked has_key? but if matz prefers the other way I am fine,
and I like that there is a consistent definition there.

Making stdlib / corelib more consistent would be great, and hopefully
gem-installable in a modular way too, so

+1

for this.

I'll copy paste Matz's remark here again, just so that others don't
have to click an external link:

"The basic naming for methods in standard class libraries are:

* use basic form (include not includes)
* put question mark for predicates
* put bang mark for "dangerous" version of methods

"is_a" and "has_key" are exceptions.  "is_a" (or "isa") used very often
for inheritance in OO context.
"has_key" has already been deprecated by "key?"

Besides that, backward incompatibility introduced by renaming them would
be unbearable."

(Note: I think matz actually meant "has_key?" rather than "has_key" in
that email back then)

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

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

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)
This topic is locked and can not be replied to.