D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Array
/
Filename :
uniq-i.ri
back
Copy
U:RDoc::AnyMethod[iI" uniq:ETI"Array#uniq;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"XReturns a new array containing those elements from +self+ that are not duplicates, ;TI"0the first occurrence always being retained.;To:RDoc::Markup::BlankLine o; ; [I"]With no block given, identifies and omits duplicate elements using method <tt>eql?</tt> ;TI"to compare elements:;T@o:RDoc::Markup::Verbatim; [I"a = [0, 0, 1, 1, 2, 2] ;TI"a.uniq # => [0, 1, 2] ;T:@format0o; ; [ I";With a block given, calls the block for each element; ;TI"Jidentifies and omits "duplicate" elements using method <tt>eql?</tt> ;TI",to compare <i>block return values</i>; ;TI"Bthat is, an element is a duplicate if its block return value ;TI"/is the same as that of a previous element:;T@o;; [I".a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb'] ;TI">a.uniq {|element| element.size } # => ["a", "aa", "aaa"] ;T; 0o; ; [I"JRelated: {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].;T: @fileI"array.c;T:0@omit_headings_from_table_of_contents_below0I":uniq -> new_array uniq {|element| ... } -> new_array ;T0[ I"();T@&FI" Array;TcRDoc::NormalClass00