⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.133
Server IP:
185.119.109.197
Server:
Linux managedhosting.chostar.me 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.1.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
self
/
root
/
usr
/
share
/
ri
/
3.0.0
/
system
/
Array
/
View File Name :
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
a.size
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