instance method
String#unpack
(::string template, ?offset: ::int) -> ::Array[::Integer | ::Float | ::String | nil]
(::string template, ?offset: ::int) { (::Integer | ::Float | ::String | nil value) -> void } -> nil
unpack(template, offset: 0) {|o| .... } → object
unpack(template, offset: 0) → array
pack.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/pack.rb, line 25
def unpack(fmt, offset: 0)
Primitive.attr! :use_block
Primitive.pack_unpack(fmt, offset)
end
Extracts data from self to form new objects; see Packed Data.
With a block given, calls the block with each unpacked object.
With no block given, returns an array containing the unpacked objects.
Related: see Converting to Non-String.
Ruby version changes
-
3.3
-
String#unpacknow raisesArgumentErrorfor unknown directives. [Bug #19150]
-
-
3.1
-
String#unpackandString#unpack1now accept anoffset:keyword argument to start the unpacking after an arbitrary number of bytes have been skipped. Ifoffsetis outside of the string boundsArgumentErroris raised. [Feature #18254]
-
See also
#unicode_normalized?
#unpack1
#unicode_normalize!
#upcase
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0