Ruby | String byteslice Method
byteslice is a String class method in Ruby which is used for the byte reference.
Parameters: Here, str is the specified string.
- A substring of one byte at that position if only a single integer passed.
- A substring starting at the offset given by the first, and a length is given by the second if the two integers passed.
- A substring containing bytes at offsets given by the range if the range is passed.
- nil if the length is negative or initial offset falls outside the string or the beginning of the range is greater than the end.
Note: If an offset is negative then it is counted from the end of the string.