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 AND operation to the source, using the mask, repeating as necessary.

Example
IO::Buffer.for("1234567890") & IO::Buffer.for("\xFF\x00\x00\xFF")
# =>
# #<IO::Buffer 0x00005589b2758480+10 INTERNAL>
# 0x00000000  31 00 00 34 35 00 00 38 39 00                   1..45..89.
See also .string #<=> .size_of #^ also in 4.0 · 3.4 · 3.3 · 3.2