-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Hash#key_index
#10016
Remove Hash#key_index
#10016
Conversation
It was added exclusively for the compiler but it's not general enough to be in the standard library.
If |
Yes. They make the API pretty ugly, in my opinion, for a very little gain. |
Github search showed this method is probably not much in use. Although I use it in crinja, but that can be changed to the same workaround as in the compiler. It should be deprecated instead of direct removal. Still I'm not 100% convinced that it should really be removed. It is useful not only for the compiler. |
Yeah... actually, it is useful, and the other methods too. Now that I think about it, we can use index from enumerable for this, right? |
Should this have a depreciation warning? I am just concerned about upgrading versions and having broken code. I dont know if that is as big of a concern before 1.0. |
1.0 will be the last version that will introduce breaking changes. It already includes a bunch of them, I don't think removing this is a big deal. The code will just fail to compile and it's very easy to make it work again. |
As I mentioned in #9952 (comment) I needed this for the compiler and added it to Hash, a really long time ago. I don't think that method is generally useful, and it was only used in one place in the compiler. Ruby doesn't have such method, so let's remove it.
As a side note, I'd also like to remove
Hash#first_key
andHash#first_value
: they are redundant because one can dohash.first[0]
andhash.first[1]
(plus they don't exist in Ruby either).