Skip to content
instance method

IO::Buffer#initialize_copy

(self object) -> self
dup → io_buffer
clone → io_buffer

Make an internal copy of the source buffer. Updates to the copy will not affect the source buffer.

Example
source = IO::Buffer.for("Hello World")
# =>
# #<IO::Buffer 0x00007fd598466830+11 EXTERNAL READONLY SLICE>
# 0x00000000  48 65 6c 6c 6f 20 57 6f 72 6c 64                Hello World
buffer = source.dup
# =>
# #<IO::Buffer 0x0000558cbec03320+11 INTERNAL>
# 0x00000000  48 65 6c 6c 6f 20 57 6f 72 6c 64                Hello World
See also #hexdump #inspect #get_values #internal? also in 3.4 · 3.3 · 3.2