End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
GDBM#shift
gdbm.shift → (key, value) or nil
ext/gdbm/gdbm.c
View on GitHub ↗
static VALUE
fgdbm_shift(VALUE obj)
{
struct dbmdata *dbmp;
GDBM_FILE dbm;
VALUE keystr, valstr;
rb_gdbm_modify(obj);
GetDBM2(obj, dbmp, dbm);
keystr = rb_gdbm_firstkey(dbm);
if (NIL_P(keystr)) return Qnil;
valstr = rb_gdbm_fetch2(dbm, keystr);
rb_gdbm_delete(obj, keystr);
return rb_assoc_new(keystr, valstr);
}
Removes a key-value-pair from this database and returns it as a two-item array [ key, value ]. Returns nil if the database is empty.