Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

IO::Buffer#^

source ^ mask → io_buffer

Generate a new buffer the same size as the source by applying the binary XOR operation to the source, using the mask, repeating as necessary.

Example
IO::Buffer.for("1234567890") ^ IO::Buffer.for("\xFF\x00\x00\xFF")
# =>
# #<IO::Buffer 0x000055a2d5d10480+10 INTERNAL>
# 0x00000000  ce 32 33 cb ca 36 37 c7 c6 30                   .23..67..0
See also #<=> #| #& #~ also in 4.0 · 3.4 · 3.3 · 3.2