Project

General

Profile

Actions

Feature #20176

open

Array#pack: support offset kwarg

Added by chucke (Tiago Cardoso) 4 months ago. Updated 4 months ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:116152]

Description

I was changing some code to use ruby 3.3's new buffer kwarg (great addition btw!) when using Array#pack. There are a few cases however, where I could perform the change, as not all my usages rely on appending; in some, I'm actually prepending it.

To solve this, I'd like to propose the offset kwarg, which declares where to add the resulting string. picking up on example from the docs:

[65, 66].pack('C*', buffer: 'foo') # => "fooAB"
[65, 66].pack('C*', buffer: 'foo', offset: 0) # => "ABfoo"
[65, 66].pack('C*', buffer: 'foo', offset: 1) # => "fABoo"
Actions

Also available in: Atom PDF

Like0
Like0Like0