Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
Returns a new Array containing values for the given keys:
h = {foo: 0, bar: 1, baz: 2}
h.values_at(:baz, :foo) # => [2, 0]
The default values are returned for any keys that are not found:
h.values_at(:hello, :foo) # => [nil, 0]
               static VALUE
rb_hash_values_at(int argc, VALUE *argv, VALUE hash)
    VALUE result = rb_ary_new2(argc);
    long i;

    for (i=0; i<argc; i++) {
        rb_ary_push(result, rb_hash_aref(hash, argv[i]));
    return result;

Was this page useful?