Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
Returns a new 2-element Array consisting of the key and value of the first-found entry whose value is == to value (see Entry Order):
h = {foo: 0, bar: 1, baz: 1}
h.rassoc(1) # => [:bar, 1]
Returns nil if no such value found.
 
               static VALUE
rb_hash_rassoc(VALUE hash, VALUE obj)
{
    VALUE args[2];

    args[0] = obj;
    args[1] = Qnil;
    rb_hash_foreach(hash, rassoc_i, (VALUE)args);
    return args[1];
}
            

Was this page useful?