mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 20:19:19 +00:00
[DOC] Tweaks for String#unpack
This commit is contained in:
parent
00521434a4
commit
43e26d02df
Notes:
git
2025-11-16 21:26:38 +00:00
16
pack.rb
16
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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user