Skip to content

Commit 43e26d0

Browse files
BurdetteLamarpeterzhu2118
authored andcommitted
[DOC] Tweaks for String#unpack
1 parent 0052143 commit 43e26d0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pack.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ def pack(fmt, buffer: nil)
1010
end
1111

1212
class String
13-
# call-seq:
14-
# unpack(template, offset: 0, &block) -> array
13+
# call-seq:
14+
# unpack(template, offset: 0) {|o| .... } -> object
15+
# unpack(template, offset: 0) -> array
1516
#
16-
# Extracts data from +self+.
17+
# Extracts data from +self+ to form new objects;
18+
# see {Packed Data}[rdoc-ref:packed_data.rdoc].
1719
#
18-
# If +block+ is not given, forming objects that become the elements
19-
# of a new array, and returns that array. Otherwise, yields each
20-
# object.
20+
# With a block given, calls the block with each unpacked object.
2121
#
22-
# See {Packed Data}[rdoc-ref:packed_data.rdoc].
22+
# With no block given, returns an array containing the unpacked objects.
23+
#
24+
# Related: see {Converting to Non-String}[rdoc-ref:String@Converting+to+Non--5CString].
2325
def unpack(fmt, offset: 0)
2426
Primitive.attr! :use_block
2527
Primitive.pack_unpack(fmt, offset)

0 commit comments

Comments
 (0)