summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'array.c')
-rw-r--r--array.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/array.c b/array.c
index a7c74a2aa4..b4216ac1d0 100644
--- a/array.c
+++ b/array.c
@@ -1778,7 +1778,8 @@ rb_ary_empty_p(VALUE ary)
VALUE
rb_ary_dup(VALUE ary)
{
- VALUE dup = rb_ary_new2(RARRAY_LEN(ary));
+ VALUE ary_class = rb_obj_class(ary);
+ VALUE dup = ary_new(ary_class ? ary_class : rb_cArray, RARRAY_LEN(ary));
MEMCPY(RARRAY_PTR(dup), RARRAY_PTR(ary), VALUE, RARRAY_LEN(ary));
ARY_SET_LEN(dup, RARRAY_LEN(ary));
return dup;