From 0c6fdc530b2edac152a8430552df7b86bb1900ef Mon Sep 17 00:00:00 2001 From: knu Date: Tue, 16 Dec 2008 08:15:21 +0000 Subject: * array.c (rb_ary_nitems, rb_ary_choice): Add a deprecation warning. * hash.c (env_index, rb_hash_index): Simplify the deprecation warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@20783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'array.c') diff --git a/array.c b/array.c index d063b06bd6..14edc9bad9 100644 --- a/array.c +++ b/array.c @@ -3067,6 +3067,8 @@ rb_ary_nitems(ary) long n = 0; VALUE *p, *pend; + rb_warn("Array#nitems is deprecated; use Array#count { |i| !i.nil? }"); + for (p = RARRAY(ary)->ptr, pend = p + RARRAY(ary)->len; p < pend; p++) { if (!NIL_P(*p)) n++; } @@ -3363,6 +3365,8 @@ rb_ary_choice(ary) { long i, j; + rb_warn("Array#choice is deprecated; use Array#sample"); + i = RARRAY(ary)->len; if (i == 0) return Qnil; j = rb_genrand_real()*i; -- cgit v1.2.3