mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00
parent
444553b528
commit
b6489e9f62
1 changed files with 4 additions and 2 deletions
|
@ -1,7 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Polyfill for String#unpack1 with the offset parameter.
|
||||
if String.instance_method(:unpack1).parameters.none? { |_, name| name == :offset }
|
||||
# Polyfill for String#unpack1 with the offset parameter. Not all Ruby engines
|
||||
# have Method#parameters implemented, so we check the arity instead if
|
||||
# necessary.
|
||||
if (unpack1 = String.instance_method(:unpack1)).respond_to?(:parameters) ? unpack1.parameters.none? { |_, name| name == :offset } : (unpack1.arity == 1)
|
||||
String.prepend(
|
||||
Module.new {
|
||||
def unpack1(format, offset: 0) # :nodoc:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue