📁 File Manager Pro
v10.0.3 | PHP: 8.1.34
Server: Apache
2026-06-22 08:36:32
📂
/ (Root)
/
opt
/
alt
/
ruby31
/
share
/
ri
/
system
/
String
📍 /opt/alt/ruby31/share/ri/system/String
🔄 Refresh
✏️
Editing: slice-i.ri
Read Only
U:RDoc::AnyMethod[iI" slice:ETI"String#slice;TF:privateo:RDoc::Markup::Document:@parts[1o:RDoc::Markup::Paragraph; [I"@Returns the substring of +self+ specified by the arguments.;To:RDoc::Markup::BlankLine o; ; [I"9When the single \Integer argument +index+ is given, ;TI"Ireturns the 1-character substring found in +self+ at offset +index+:;T@o:RDoc::Markup::Verbatim; [I"'bar'[2] # => "r" ;T:@format0o; ; [I"CCounts backward from the end of +self+ if +index+ is negative:;T@o;; [I"'foo'[-3] # => "f" ;T; 0o; ; [I".Returns +nil+ if +index+ is out of range:;T@o;; [I"'foo'[3] # => nil ;TI"'foo'[-4] # => nil ;T; 0o; ; [I"FWhen the two \Integer arguments +start+ and +length+ are given, ;TI"Sreturns the substring of the given +length+ found in +self+ at offset +start+:;T@o;; [I"'foo'[0, 2] # => "fo" ;TI"'foo'[0, 0] # => "" ;T; 0o; ; [I"CCounts backward from the end of +self+ if +start+ is negative:;T@o;; [I"'foo'[-2, 2] # => "oo" ;T; 0o; ; [I"[Special case: returns a new empty \String if +start+ is equal to the length of +self+:;T@o;; [I"'foo'[3, 2] # => "" ;T; 0o; ; [I".Returns +nil+ if +start+ is out of range:;T@o;; [I"'foo'[4, 2] # => nil ;TI"'foo'[-4, 2] # => nil ;T; 0o; ; [I"CReturns the trailing substring of +self+ if +length+ is large:;T@o;; [I"'foo'[1, 50] # => "oo" ;T; 0o; ; [I"+Returns +nil+ if +length+ is negative:;T@o;; [I"'foo'[0, -1] # => nil ;T; 0o; ; [I"7When the single \Range argument +range+ is given, ;TI"Aderives +start+ and +length+ values from the given +range+, ;TI"!and returns values as above:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"@<tt>'foo'[0..1]</tt> is equivalent to <tt>'foo'[0, 2]</tt>.;To;;0; [o; ; [I"A<tt>'foo'[0...1]</tt> is equivalent to <tt>'foo'[0, 1]</tt>.;T@o; ; [ I"2When the \Regexp argument +regexp+ is given, ;TI"/and the +capture+ argument is <tt>0</tt>, ;TI";returns the first matching substring found in +self+, ;TI"or +nil+ if none found:;T@o;; [ I"'foo'[/o/] # => "o" ;TI"'foo'[/x/] # => nil ;TI"s = 'hello there' ;TI""s[/[aeiou](.)\1/] # => "ell" ;TI"%s[/[aeiou](.)\1/, 0] # => "ell" ;T; 0o; ; [ I"8If argument +capture+ is given and not <tt>0</tt>, ;TI"eit should be either an \Integer capture group index or a \String or \Symbol capture group name; ;TI"8the method call returns only the specified capture ;TI"H(see {Regexp Capturing}[Regexp.html#class-Regexp-label-Capturing]):;T@o;; [ I"s = 'hello there' ;TI"#s[/[aeiou](.)\1/, 1] # => "l" ;TI"Hs[/(?<vowel>[aeiou])(?<non_vowel>[^aeiou])/, "non_vowel"] # => "l" ;TI"Cs[/(?<vowel>[aeiou])(?<non_vowel>[^aeiou])/, :vowel] # => "e" ;T; 0o; ; [I"SIf an invalid capture group index is given, +nil+ is returned. If an invalid ;TI"9capture group name is given, +IndexError+ is raised.;T@o; ; [I"<When the single \String argument +substring+ is given, ;TI"Areturns the substring from +self+ if found, otherwise +nil+:;T@o;; [I"'foo'['oo'] # => "oo" ;TI"'foo'['xx'] # => nil ;T; 0o; ; [I",String#slice is an alias for String#[].;T: @fileI" string.c;T:0@omit_headings_from_table_of_contents_below000[ I"(*args);T@~FI"String;TcRDoc::NormalClass0[@�FI"[];T
💾 Save Changes
❌ Cancel