diff --git a/pack.rb b/pack.rb index 5cadc0cc8b..d57788b222 100644 --- a/pack.rb +++ b/pack.rb @@ -10,16 +10,18 @@ class Array end class String - # call-seq: - # unpack(template, offset: 0, &block) -> array + # call-seq: + # unpack(template, offset: 0) {|o| .... } -> object + # unpack(template, offset: 0) -> array # - # Extracts data from +self+. + # Extracts data from +self+ to form new objects; + # see {Packed Data}[rdoc-ref:packed_data.rdoc]. # - # If +block+ is not given, forming objects that become the elements - # of a new array, and returns that array. Otherwise, yields each - # object. + # With a block given, calls the block with each unpacked object. # - # See {Packed Data}[rdoc-ref:packed_data.rdoc]. + # With no block given, returns an array containing the unpacked objects. + # + # Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non--5CString]. def unpack(fmt, offset: 0) Primitive.attr! :use_block Primitive.pack_unpack(fmt, offset)