summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/object.c b/object.c
index 6694e2f8fa..69e99f60b0 100644
--- a/object.c
+++ b/object.c
@@ -1270,10 +1270,16 @@ rb_Array(val)
val = rb_funcall(val, to_ary, 0);
}
else {
- val = rb_funcall(val, rb_intern("to_a"), 0);
+ to_ary = rb_intern("to_a");
+ if (rb_respond_to(val, to_ary)) {
+ val = rb_funcall(val, to_ary, 0);
+ }
+ else {
+ val = rb_ary_new3(1, val);
+ }
}
if (TYPE(val) != T_ARRAY) {
- rb_raise(rb_eTypeError, "`to_a' did not return Array");
+ rb_raise(rb_eTypeError, "`%s' did not return Array", rb_id2name(to_ary));
}
return val;
}