Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
IO::Buffer#null?
() -> bool
null? → true or false
io_buffer.c
View on GitHub ↗
static VALUE
rb_io_buffer_null_p(VALUE self)
{
struct rb_io_buffer_view *buffer = get_io_buffer_view(self);
void *base = NULL;
size_t size = 0;
io_buffer_try_get_bytes(buffer, &base, &size);
return RBOOL(base == NULL);
}
Returns whether the buffer has no recorded base address.
A buffer is null if it was freed with free, transferred with transfer, or was never allocated in the first place. A zero-sized buffer or slice may have a non-null address, so null? and empty? are distinct properties.
Example
buffer = IO::Buffer.new(0) buffer.null? #=> true buffer = IO::Buffer.new(4) buffer.null? #=> false buffer.free buffer.null? #=> true