mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 14:05:02 +02:00
12 lines
361 B
Ruby
12 lines
361 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Polyfill for String#unpack1 with the offset parameter.
|
|
if String.instance_method(:unpack1).parameters.none? { |_, name| name == :offset }
|
|
String.prepend(
|
|
Module.new {
|
|
def unpack1(format, offset: 0) # :nodoc:
|
|
offset == 0 ? super(format) : self[offset..].unpack1(format) # steep:ignore
|
|
end
|
|
}
|
|
)
|
|
end
|