Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/sorbet/eraser.rb,
lib/sorbet/eraser/bytesplice.rb
Instance Method Summary collapse
-
#bytesplice(range, value) ⇒ Object
This is a polyfill for the String#bytesplice method that didn’t exist before Ruby 3.2.0, and didn’t return the receiver until 3.2.1.
Instance Method Details
#bytesplice(range, value) ⇒ Object
This is a polyfill for the String#bytesplice method that didn’t exist before Ruby 3.2.0, and didn’t return the receiver until 3.2.1.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/sorbet/eraser/bytesplice.rb', line 6 def bytesplice(range, value) previous_encoding = encoding begin force_encoding(Encoding::ASCII_8BIT) self[range] = value ensure force_encoding(previous_encoding) end self end |