Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
IO::Buffer#~
~source → io_buffer
io_buffer.c
View on GitHub ↗
static VALUE
io_buffer_not(VALUE self)
{
struct rb_io_buffer_view *buffer = get_io_buffer_view(self);
const void *base;
size_t size;
io_buffer_get_bytes_for_reading(buffer, &base, &size);
VALUE output = rb_io_buffer_new(NULL, size, io_flags_for_size(size));
struct rb_io_buffer_view *output_buffer = get_io_buffer_view(output);
memory_not(output_buffer->base, base, size);
return output;
}
Generate a new buffer the same size as the source by applying the unary NOT operation to the source.
Example
~IO::Buffer.for("1234567890") # => # #<IO::Buffer 0x000055a5ac42f120+10 INTERNAL> # 0x00000000 ce cd cc cb ca c9 c8 c7 c6 cf ..........