Ruby/String/slice
Материал из Wiki.crossplatform.ru
Negative index in slice
s = "My kingdom for a string!" s.slice(-7,3) # => "str" s[-7,6] # => "string"
Slice a string
string = "My first string" # => "My first string" string.slice(3, 5) # => "first"
String slice and index
s = "My kingdom for a string!" s.slice(3) # => 107 s[3] # => 107 107.chr # => "k" s.slice(3,1) # => "k" s[3,1] # => "k"