Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
String#unpack1
(::string template, ?offset: ::int) -> (::Integer | ::Float | ::String)?
unpack1(template, offset: 0) → object
pack.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/pack.rb, line 33
def unpack1(fmt, offset: 0)
Primitive.pack_unpack1(fmt, offset)
end
Like String#unpack, but unpacks and returns only the first extracted object. See Packed Data.
Ruby version changes
-
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]
-