open(*args)
public
If called without a block, this is the same as SDBM.new.
If a block is given, the new database
will be passed to the block and will be safely closed after the block has
executed.
Example:
require 'sdbm'
SDBM.open('my_database') do |db|
db['hello'] = 'world'
end
static VALUE
fsdbm_s_open(int argc, VALUE *argv, VALUE klass)
{
VALUE obj = fsdbm_alloc(klass);
if (NIL_P(fsdbm_initialize(argc, argv, obj))) {
return Qnil;
}
if (rb_block_given_p()) {
return rb_ensure(rb_yield, obj, fsdbm_close, obj);
}
return obj;
}