diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-02-10 09:40:13 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-02-10 09:40:13 +0000 |
commit | ab24be4e98660f4fbef44a03262f25988a260b9f (patch) | |
tree | cb5aa15714754619f0848fb2dacff076246cb74d /array.c | |
parent | b53549941d4d543191c91054e974598b0e29210b (diff) |
* array.c (rb_ary_to_a): return value should be an Array if the
receiver is an instance of subclass of Array.
* string.c (rb_str_to_s): return value should be a String if the
receiver is an instance of subclass of String.
* eval.c (rb_call): calls method_missing when superclass method
does not exist.
* eval.c (rb_f_missing): now handles "no super" case.
* object.c (rb_obj_ivar_get): Object#instance_variable_get: new
method to get instance variable value without eval(). [new]
* object.c (rb_obj_ivar_set): Object#instance_variable_set: new
method to set instance variable value without eval(). [new]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -1001,6 +1001,18 @@ static VALUE rb_ary_to_a(ary) VALUE ary; { + if (rb_obj_class(ary) != rb_cArray) { + VALUE dup = rb_ary_new2(RARRAY(ary)->len); + rb_ary_replace(dup, ary); + return dup; + } + return ary; +} + +static VALUE +rb_ary_to_ary_m(ary) + VALUE ary; +{ return ary; } @@ -1891,7 +1903,7 @@ Init_Array() rb_define_method(rb_cArray, "to_s", rb_ary_to_s, 0); rb_define_method(rb_cArray, "inspect", rb_ary_inspect, 0); rb_define_method(rb_cArray, "to_a", rb_ary_to_a, 0); - rb_define_method(rb_cArray, "to_ary", rb_ary_to_a, 0); + rb_define_method(rb_cArray, "to_ary", rb_ary_to_ary_m, 0); rb_define_method(rb_cArray, "frozen?", rb_ary_frozen_p, 0); rb_define_method(rb_cArray, "==", rb_ary_equal, 1); |