But if you’re coming from C, and you think of a string as an array of bytes, Ruby can
accommodate you. Selecting a single byte from a string returns that byte as a number:


string.byteslice(3) + string.byteslice(4) + string.byteslice(5)
+ string.byteslice(6) + string.byteslice(7)
# => "first"


And if you come from Python, and you like that language’s slice notation, you can
just as easily chop up the string that way:
string[3, 5]
# => "first"