diff options
author | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-02 04:23:56 +0000 |
---|---|---|
committer | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-04-02 04:23:56 +0000 |
commit | 373282f6656d3d3d989d261e7a95f8e81b5c9712 (patch) | |
tree | d97ac705189193b6c1474b5f0480f4e64ffeb6c7 | |
parent | 4f8df7dcc42119a11c568a12b3e50f01553f4e4c (diff) | |
download | ruby-373282f6656d3d3d989d261e7a95f8e81b5c9712.tar.gz |
* hash.c (env_key): ENV.index is deprecated as well as Hash#index.
use ENV.key instead. [ruby-dev:25974]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | hash.c | 15 |
2 files changed, 17 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Sat Apr 2 13:23:17 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp> + + * hash.c (env_key): ENV.index is deprecated as well as Hash#index. + use ENV.key instead. [ruby-dev:25974] + Sat Apr 2 02:19:11 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> * ext/tk/lib/tk.rb (TkWindow.initialize): accept 'without_creating' @@ -591,8 +591,8 @@ key_i(key, value, args) * Returns the key for a given value. If not found, returns <code>nil</code>. * * h = { "a" => 100, "b" => 200 } - * h.index(200) #=> "b" - * h.index(999) #=> nil + * h.key(200) #=> "b" + * h.key(999) #=> nil * */ @@ -2317,7 +2317,7 @@ env_has_value(dmy, value) } static VALUE -env_index(dmy, value) +env_key(dmy, value) VALUE dmy, value; { char **env; @@ -2343,6 +2343,14 @@ env_index(dmy, value) } static VALUE +env_index(dmy, value) + VALUE dmy, value; +{ + rb_warn("ENV.index is deprecated; use ENV.key"); + return env_key(dmy, value); +} + +static VALUE env_to_hash() { char **env; @@ -2559,6 +2567,7 @@ Init_Hash() rb_define_singleton_method(envtbl,"rehash", env_none, 0); rb_define_singleton_method(envtbl,"to_a", env_to_a, 0); rb_define_singleton_method(envtbl,"to_s", env_to_s, 0); + rb_define_singleton_method(envtbl,"key", env_key, 1); rb_define_singleton_method(envtbl,"index", env_index, 1); rb_define_singleton_method(envtbl,"size", env_size, 0); rb_define_singleton_method(envtbl,"length", env_size, 0); |