summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-26 08:22:33 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-26 08:22:33 +0000
commitb4fd4d6018a8ad72f69912606c60ec42ee3b62b8 (patch)
tree7d8e6794c8b14219eb3a1902d6538ea27a239065 /object.c
parentea325deab0729bf17d3f366aa6369d93a4db54fd (diff)
* 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
Diffstat (limited to 'object.c')
-rw-r--r--object.c32
1 files changed, 14 insertions, 18 deletions
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)