From b4fd4d6018a8ad72f69912606c60ec42ee3b62b8 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 26 May 2003 08:22:33 +0000 Subject: * eval.c (Init_Proc): Block/Proc separation. [huge change] * eval.c (block_arity): returns exact arity number for Procs out of methods. also gives 1 for {|a|..}. * string.c (rb_str_match): revert use of String#index for invocation like string =~ string. * eval.c (rb_Array): move Object#to_a exclusion hack from splat_value(). need to be in eval.c for a while. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- object.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'object.c') diff --git a/object.c b/object.c index d355c01fa4..a559f12f1d 100644 --- a/object.c +++ b/object.c @@ -1288,34 +1288,30 @@ rb_f_string(obj, arg) return rb_String(arg); } +#if 0 VALUE rb_Array(val) VALUE val; { - ID to_ary; + VALUE tmp = rb_check_array_type(val); + ID to_a; - if (NIL_P(val)) { - rb_raise(rb_eTypeError, "cannot convert nil into Array"); - } - if (TYPE(val) == T_ARRAY) return val; - to_ary = rb_intern("to_ary"); - if (rb_respond_to(val, to_ary)) { - val = rb_funcall(val, to_ary, 0); - } - else { - to_ary = rb_intern("to_a"); - if (rb_respond_to(val, to_ary)) { - val = rb_funcall(val, to_ary, 0); + if (NIL_P(tmp)) { + to_a = rb_intern("to_a"); + if (rb_respond_to(val, to_a)) { + val = rb_funcall(val, to_a, 0); + if (TYPE(val) != T_ARRAY) { + rb_raise(rb_eTypeError, "`to_a' did not return Array"); + } + return val; } else { - val = rb_ary_new3(1, val); + return rb_ary_new3(1, val); } } - if (TYPE(val) != T_ARRAY) { - rb_raise(rb_eTypeError, "`%s' did not return Array", rb_id2name(to_ary)); - } - return val; + return tmp; } +#endif static VALUE rb_f_array(obj, arg) -- cgit v1.2.3