Actions
Feature #14783
openString#chars_at / String#bytes_at
Feature #14783:
String#chars_at / String#bytes_at
Status:
Open
Assignee:
-
Target version:
-
Description
I just wanted to extract characters at certain indices from a string and noticed that there's no values_at counterpart for String.
I'd therefore like to propose two new String methods:
chars_at(selector, ...) → new_strbytes_at(selector, ...) → new_str
which work basically like Array#values_at, e.g.:
string = 'hello, world!'
string.chars_at(0, 5, 7, 12) #=> "h,w!"
string.chars_at(0..4, 7..11) #=> "helloworld"
Actions