%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/cpanel/ea-ruby24/root/usr/share/ri/system/Array/
Upload File :
Create Path :
Current File : //proc/self/root/opt/cpanel/ea-ruby24/root/usr/share/ri/system/Array/new-c.ri

U:RDoc::AnyMethod[iI"new:ETI"Array::new;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph;	[I"Returns a new array.;To:RDoc::Markup::BlankLineo;
;	[	I"OIn the first form, if no arguments are sent, the new array will be empty. ;TI"PWhen a +size+ and an optional +default+ are sent, an array is created with ;TI"S+size+ copies of +default+.  Take notice that all elements will reference the ;TI"same object +default+.;T@o;
;	[I"LThe second form creates a copy of the array passed as a parameter (the ;TI"<array is generated by calling to_ary on the parameter).;T@o:RDoc::Markup::Verbatim;	[
I"%first_array = ["Matz", "Guido"]
;TI"
;TI"Asecond_array = Array.new(first_array) #=> ["Matz", "Guido"]
;TI"
;TI"5first_array.equal? second_array       #=> false
;T:@format0o;
;	[I"OIn the last form, an array of the given size is created.  Each element in ;TI"Mthis array is created by passing the element's index to the given block ;TI""and storing the return value.;T@o;;	[I"(Array.new(3){ |index| index ** 2 }
;TI"# => [0, 1, 4]
;T;
0S:RDoc::Markup::Heading:
leveli:	textI"Common gotchas;T@o;
;	[I"LWhen sending the second parameter, the same object will be used as the ;TI"&value for all the array elements:;T@o;;	[
I" a = Array.new(2, Hash.new)
;TI"# => [{}, {}]
;TI"
;TI"a[0]['cat'] = 'feline'
;TI"3a # => [{"cat"=>"feline"}, {"cat"=>"feline"}]
;TI"
;TI"a[1]['cat'] = 'Felix'
;TI"1a # => [{"cat"=>"Felix"}, {"cat"=>"Felix"}]
;T;
0o;
;	[I"NSince all the Array elements store the same hash, changes to one of them ;TI"will affect them all.;T@o;
;	[I"DIf multiple copies are what you want, you should use the block ;TI"Fversion which uses the result of that block each time an element ;TI"*of the array needs to be initialized:;T@o;;	[I"#a = Array.new(2) { Hash.new }
;TI"a[0]['cat'] = 'feline'
;TI"#a # => [{"cat"=>"feline"}, {}];T;
0:
@fileI"array.c;T:0@omit_headings_from_table_of_contents_below0I"VArray.new(size=0, default=nil)
Array.new(array)
Array.new(size) {|index| block }
;T0[I"(p1 = v1, p2 = v2);T@GFI"
Array;TcRDoc::NormalClass00

Zerion Mini Shell 1.0