File: //usr/share/ri/3.0.0/system/Array/sample-i.ri
U:RDoc::AnyMethod[iI"sample:ETI"Array#sample;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I")Returns random elements from +self+.;To:RDoc::Markup::BlankLine o;
; [I"GWhen no arguments are given, returns a random element from +self+:;To:RDoc::Markup::Verbatim; [I")a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
;TI"a.sample # => 3
;TI"a.sample # => 8
;T:@format0o;
; [I"'If +self+ is empty, returns +nil+.;T@o;
; [I"LWhen argument +n+ is given, returns a new \Array containing +n+ random ;TI"elements from +self+:;To;; [I" a.sample(3) # => [8, 9, 2]
;TI"*a.sample(6) # => [9, 6, 10, 3, 1, 4]
;T;
0o;
; [I"3Returns no more than <tt>a.size</tt> elements ;TI"0(because no new duplicates are introduced):;To;; [I"?a.sample(a.size * 2) # => [6, 4, 1, 8, 5, 9, 10, 2, 3, 7]
;T;
0o;
; [I"'But +self+ may contain duplicates:;To;; [I"a = [1, 1, 1, 2, 2, 3]
;TI"2a.sample(a.size * 2) # => [1, 1, 3, 2, 1, 2]
;T;
0o;
; [I"3Returns a new empty \Array if +self+ is empty.;T@o;
; [I"PThe optional +random+ argument will be used as the random number generator:;To;; [I")a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
;TI"/a.sample(random: Random.new(1)) #=> 6
;TI":a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2];T;
0:
@fileI"
array.rb;T:0@omit_headings_from_table_of_contents_below0I"Warray.sample(random: Random) -> object
array.sample(n, random: Random) -> new_ary
;T0[ I"((n = (ary = false), random: Random);T@;FI"
Array;TcRDoc::NormalClass00