D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Array
/
Filename :
fetch_values-i.ri
back
Copy
U:RDoc::AnyMethod[iI"fetch_values:ETI"Array#fetch_values;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"PWith no block given, returns a new array containing the elements of +self+ ;TI"Mat the offsets specified by +indexes+. Each of the +indexes+ must be an ;TI"a{integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects]:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [ I"a = [:foo, :bar, :baz] ;TI".a.fetch_values(2, 0) # => [:baz, :foo] ;TI".a.fetch_values(2.1, 0) # => [:baz, :foo] ;TI"$a.fetch_values # => [] ;T:@format0o; ; [I"FFor a negative index, counts backwards from the end of the array:;T@o;; [I"+a.fetch_values(-2, -1) # [:bar, :baz] ;T; 0o; ; [I"NWhen no block is given, raises an exception if any index is out of range.;T@o; ; [I"(With a block given, for each index:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"DIf the index is in range, uses an element of +self+ (as above).;To;;0; [o; ; [I"QOtherwise, calls the block with the index and uses the block's return value.;T@o; ; [I" Example:;T@o;; [I"a = [:foo, :bar, :baz] ;TI":a.fetch_values(1, 0, 42, 777) { |index| index.to_s } ;TI"$# => [:bar, :foo, "42", "777"] ;T; 0o; ; [I"NRelated: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].;T: @fileI" array.rb;T:0@omit_headings_from_table_of_contents_below0I"]fetch_values(*indexes) -> new_array fetch_values(*indexes) { |index| ... } -> new_array ;T0[ I"(*indexes, &block);T@:FI" Array;TcRDoc::NormalClass00