diff options
-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); |