Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

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, &block) → array

Extracts data from self.

If block is not given, forming objects that become the elements of a new array, and returns that array. Otherwise, yields each object.

See Packed Data.

Ruby version changes

  1. 3.3
  2. 3.1