π File Manager Pro
v10.0.3 | PHP: 8.1.34
Server: Apache
2026-06-21 22:16:18
π
/ (Root)
/
opt
/
alt
/
ruby27
/
share
/
ri
/
system
/
Array
π /opt/alt/ruby27/share/ri/system/Array
π Refresh
βοΈ
Editing: sample-i.ri
Read Only
U:RDoc::AnyMethod[iI"sample:ETI"Array#sample;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"CChoose a random element or +n+ random elements from the array.;To:RDoc::Markup::BlankLine o; ; [I"OThe elements are chosen by using random and unique indices into the array ;TI"Oin order to ensure that an element doesn't repeat itself unless the array ;TI"*already contained duplicate elements.;T@o; ; [I"LIf the array is empty the first form returns +nil+ and the second form ;TI"returns an empty array.;T@o:RDoc::Markup::Verbatim; [I"+a = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] ;TI"a.sample #=> 7 ;TI"'a.sample(4) #=> [6, 4, 2, 5] ;T:@format0o; ; [I"MThe optional +rng+ argument will be used as the random number generator.;T@o;; [I"/a.sample(random: Random.new(1)) #=> 6 ;TI":a.sample(4, random: Random.new(1)) #=> [6, 10, 9, 2];T; 0: @fileI"array.c;T:0@omit_headings_from_table_of_contents_below0I"οΏ½ary.sample -> obj ary.sample(random: rng) -> obj ary.sample(n) -> new_ary ary.sample(n, random: rng) -> new_ary ;T0[ I"(*args);T@$FI" Array;TcRDoc::NormalClass00
πΎ Save Changes
β Cancel