D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Array
/
Filename :
insert-i.ri
back
Copy
U:RDoc::AnyMethod[iI"insert:ETI"Array#insert;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"8Inserts the given +objects+ as elements of +self+; ;TI"returns +self+.;To:RDoc::Markup::BlankLine o; ; [I"5When +index+ is non-negative, inserts +objects+ ;TI",_before_ the element at offset +index+:;T@o:RDoc::Markup::Verbatim; [I"2a = ['a', 'b', 'c'] # => ["a", "b", "c"] ;TI">a.insert(1, :x, :y, :z) # => ["a", :x, :y, :z, "b", "c"] ;T:@format0o; ; [I"TExtends the array if +index+ is beyond the array (<tt>index >= self.size</tt>):;T@o;; [I"2a = ['a', 'b', 'c'] # => ["a", "b", "c"] ;TI"Ha.insert(5, :x, :y, :z) # => ["a", "b", "c", nil, nil, :x, :y, :z] ;T; 0o; ; [I"1When +index+ is negative, inserts +objects+ ;TI">_after_ the element at offset <tt>index + self.size</tt>:;T@o;; [I"3a = ['a', 'b', 'c'] # => ["a", "b", "c"] ;TI"?a.insert(-2, :x, :y, :z) # => ["a", "b", :x, :y, :z, "c"] ;T; 0o; ; [I"+With no +objects+ given, does nothing:;T@o;; [ I".a = ['a', 'b', 'c'] # => ["a", "b", "c"] ;TI".a.insert(1) # => ["a", "b", "c"] ;TI".a.insert(50) # => ["a", "b", "c"] ;TI".a.insert(-50) # => ["a", "b", "c"] ;T; 0o; ; [I"WRaises IndexError if +objects+ are given and +index+ is negative and out of range.;T@o; ; [I"PRelated: see {Methods for Assigning}[rdoc-ref:Array@Methods+for+Assigning].;T: @fileI"array.c;T:0@omit_headings_from_table_of_contents_below0I"%insert(index, *objects) -> self ;T0[ I"(*args);T@6FI" Array;TcRDoc::NormalClass00