2014-10-23 08:42:57 -04:00
|
|
|
#include "ruby.h"
|
|
|
|
|
2014-12-24 01:58:48 -05:00
|
|
|
extern VALUE rb_hash_delete_entry(VALUE hash, VALUE key);
|
|
|
|
|
2014-10-23 08:42:57 -04:00
|
|
|
static VALUE
|
|
|
|
hash_delete(VALUE hash, VALUE key)
|
|
|
|
{
|
2014-12-23 21:53:37 -05:00
|
|
|
VALUE ret = rb_hash_delete_entry(hash, key);
|
2014-10-23 10:18:32 -04:00
|
|
|
return ret == Qundef ? Qnil : rb_ary_new_from_values(1, &ret);
|
2014-10-23 08:42:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Init_delete(VALUE klass)
|
|
|
|
{
|
2014-10-23 10:18:32 -04:00
|
|
|
rb_define_method(klass, "delete!", hash_delete, 1);
|
2014-10-23 08:42:57 -04:00
|
|
|
}
|