Skip to content
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

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

  1. 3.3
  2. 3.1