End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
DBM#to_a
dbm.to_a → array
ext/dbm/dbm.c
View on GitHub ↗
static VALUE
fdbm_to_a(VALUE obj)
{
datum key, val;
struct dbmdata *dbmp;
DBM *dbm;
VALUE ary;
GetDBM2(obj, dbmp, dbm);
ary = rb_ary_new();
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
val = dbm_fetch(dbm, key);
rb_ary_push(ary, rb_assoc_new(rb_str_new(key.dptr, key.dsize),
rb_str_new(val.dptr, val.dsize)));
}
return ary;
}
Converts the contents of the database to an array of [key, value] arrays, and returns it.