⚝
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 :
slice-i.ri
U:RDoc::AnyMethod[iI" slice:ETI"Array#slice;TF:publico:RDoc::Markup::Document:@parts[&o:RDoc::Markup::Paragraph; [I":Returns elements from +self+; does not modify +self+.;To:RDoc::Markup::BlankLine o; ; [I"]When a single \Integer argument +index+ is given, returns the element at offset +index+:;To:RDoc::Markup::Verbatim; [ I"a = [:foo, 'bar', 2] ;TI"a[0] # => :foo ;TI"a[2] # => 2 ;TI"a # => [:foo, "bar", 2] ;T:@format0o; ; [I"BIf +index+ is negative, counts relative to the end of +self+:;To;; [I"a = [:foo, 'bar', 2] ;TI"a[-1] # => 2 ;TI"a[-2] # => "bar" ;T; 0o; ; [I"/If +index+ is out of range, returns +nil+.;T@o; ; [I"AWhen two \Integer arguments +start+ and +length+ are given, ;TI"freturns a new \Array of size +length+ containing successive elements beginning at offset +start+:;To;; [I"a = [:foo, 'bar', 2] ;TI" a[0, 2] # => [:foo, "bar"] ;TI"a[1, 2] # => ["bar", 2] ;T; 0o; ; [I"FIf
start + length
is greater than
self.length
, ;TI"9returns all elements from offset +start+ to the end:;To;; [ I"a = [:foo, 'bar', 2] ;TI"#a[0, 4] # => [:foo, "bar", 2] ;TI"a[1, 3] # => ["bar", 2] ;TI"a[2, 2] # => [2] ;T; 0o; ; [I">If
start == self.size
and
length >= 0
, ;TI" returns a new empty \Array.;T@o; ; [I",If +length+ is negative, returns +nil+.;T@o; ; [I"5When a single \Range argument +range+ is given, ;TI"0treats
range.min
as +start+ above ;TI"/and
range.size
as +length+ above:;To;; [I"a = [:foo, 'bar', 2] ;TI" a[0..1] # => [:foo, "bar"] ;TI"a[1..2] # => ["bar", 2] ;T; 0o; ; [I"QSpecial case: If
range.start == a.size
, returns a new empty \Array.;T@o; ; [I"NIf
range.end
is negative, calculates the end index from the end:;To;; [ I"a = [:foo, 'bar', 2] ;TI"$a[0..-1] # => [:foo, "bar", 2] ;TI"!a[0..-2] # => [:foo, "bar"] ;TI"a[0..-3] # => [:foo] ;T; 0o; ; [I"RIf
range.start
is negative, calculates the start index from the end:;To;; [ I"a = [:foo, 'bar', 2] ;TI"a[-1..2] # => [2] ;TI"a[-2..2] # => ["bar", 2] ;TI"$a[-3..2] # => [:foo, "bar", 2] ;T; 0o; ; [I"JIf
range.start
is larger than the array size, returns +nil+.;To;; [ I"a = [:foo, 'bar', 2] ;TI"a[4..1] # => nil ;TI"a[4..0] # => nil ;TI"a[4..-1] # => nil ;T; 0o; ; [I"LWhen a single Enumerator::ArithmeticSequence argument +aseq+ is given, ;TI"Kreturns an Array of elements corresponding to the indexes produced by ;TI"the sequence.;To;; [I"7a = ['--', 'data1', '--', 'data2', '--', 'data3'] ;TI"7a[(1..).step(2)] # => ["data1", "data2", "data3"] ;T; 0o; ; [I"SUnlike slicing with range, if the start or the end of the arithmetic sequence ;TI"2is larger than array size, throws RangeError.;To;; [ I"7a = ['--', 'data1', '--', 'data2', '--', 'data3'] ;TI"a[(1..11).step(2)] ;TI"3# RangeError (((1..11).step(2)) out of range) ;TI"a[(7..).step(2)] ;TI"1# RangeError (((7..).step(2)) out of range) ;T; 0o; ; [I"QIf given a single argument, and its type is not one of the listed, tries to ;TI";convert it to Integer, and raises if it is impossible:;To;; [I"a = [:foo, 'bar', 2] ;TI"I# Raises TypeError (no implicit conversion of Symbol into Integer): ;TI" a[:foo] ;T; 0o; ; [I"*Array#slice is an alias for Array#[].;T: @fileI"array.c;T:0@omit_headings_from_table_of_contents_below000[ I"(*args);T@€FI" Array;TcRDoc::NormalClass0[@ƒFI"[];T