mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 14:05:02 +02:00
parent
444553b528
commit
b6489e9f62
1 changed files with 4 additions and 2 deletions
|
@ -1,7 +1,9 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Polyfill for String#unpack1 with the offset parameter.
|
# Polyfill for String#unpack1 with the offset parameter. Not all Ruby engines
|
||||||
if String.instance_method(:unpack1).parameters.none? { |_, name| name == :offset }
|
# 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(
|
String.prepend(
|
||||||
Module.new {
|
Module.new {
|
||||||
def unpack1(format, offset: 0) # :nodoc:
|
def unpack1(format, offset: 0) # :nodoc:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue