End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
GDBM#key?
gdbm.key?(k) → true or false
ext/gdbm/gdbm.c
View on GitHub ↗
static VALUE
fgdbm_has_key(VALUE obj, VALUE keystr)
{
datum key;
struct dbmdata *dbmp;
GDBM_FILE dbm;
long len;
ExportStringValue(keystr);
len = RSTRING_LENINT(keystr);
if (TOO_LONG(len)) return Qfalse;
key.dptr = RSTRING_PTR(keystr);
key.dsize = (int)len;
GetDBM2(obj, dbmp, dbm);
if (gdbm_exists(dbm, key))
return Qtrue;
return Qfalse;
}
Alias of #include?
Returns true if the given key k exists within the database. Returns false otherwise.