Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Array#pack
(::string fmt, ?buffer: ::String?) -> ::String
pack(template, buffer: nil) → string
pack.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pack.rb, line 7
def pack(fmt, buffer: nil)
Primitive.pack_pack(fmt, buffer)
end
Formats each element in self into a binary string; returns that string. See Packed Data.
Ruby version changes
-
4.1
-
Array#packaccepts new formatsRandrfor unsigned and signed LEB128 encoded integers. [Feature #21785] -
Array#packaccepts new formatsx!and@!to align the current offset to a byte boundary or to the ABI alignment of another directive. [Feature #22185]
-
-
3.3
-
Array#packnow raisesArgumentErrorfor unknown directives. [Bug #19150]
-