[DOC] Tweaks for Array#to_a

This commit is contained in:
BurdetteLamar 2024-10-22 09:23:16 -05:00 committed by Peter Zhu
parent e288604eb3
commit 3a327e1c18
Notes: git 2024-10-22 15:24:51 +00:00

18
array.c
View File

@ -2985,21 +2985,17 @@ rb_ary_to_s(VALUE ary)
* call-seq: * call-seq:
* to_a -> self or new_array * to_a -> self or new_array
* *
* When +self+ is an instance of +Array+, returns +self+: * When +self+ is an instance of +Array+, returns +self+.
* *
* a = [:foo, 'bar', 2] * Otherwise, returns a new array containing the elements of +self+:
* a.to_a # => [:foo, "bar", 2]
*
* Otherwise, returns a new +Array+ containing the elements of +self+:
* *
* class MyArray < Array; end * class MyArray < Array; end
* a = MyArray.new(['foo', 'bar', 'two']) * my_a = MyArray.new(['foo', 'bar', 'two'])
* a.instance_of?(Array) # => false * a = my_a.to_a
* a.kind_of?(Array) # => true * a # => ["foo", "bar", "two"]
* a1 = a.to_a * a.class # => Array # Not MyArray.
* a1 # => ["foo", "bar", "two"]
* a1.class # => Array # Not MyArray
* *
* Related: see {Methods for Converting}[rdoc-ref:Array@Methods+for+Converting].
*/ */
static VALUE static VALUE