Method: Array#dig
- Defined in:
- array.c
#dig(index, *identifiers) ⇒ Object
Finds and returns the object in nested object specified by index and identifiers; the nested objects may be instances of various classes. See Dig Methods.
Examples:
a = [:foo, [:bar, :baz, [:bat, :bam]]]
a.dig(1) # => [:bar, :baz, [:bat, :bam]]
a.dig(1, 2) # => [:bat, :bam]
a.dig(1, 2, 0) # => :bat
a.dig(1, 2, 3) # => nil
Related: see Methods for Fetching.
8033 8034 8035 8036 8037 8038 8039 8040 8041 |
# File 'array.c', line 8033 static VALUE rb_ary_dig(int argc, VALUE *argv, VALUE self) { rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); self = rb_ary_at(self, *argv); if (!--argc) return self; ++argv; return rb_obj_dig(argc, argv, self, Qnil); } |