diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | array.c | 4 | ||||
-rw-r--r-- | hash.c | 4 | ||||
-rw-r--r-- | struct.c | 14 |
4 files changed, 25 insertions, 4 deletions
@@ -1,3 +1,10 @@ +Tue Nov 17 11:25:05 2015 Eric Turner <ericturnerdev@gmail.com> + + * array.c (rb_ary_dig), hash.c (rb_hash_dig): [DOC] Update + comments describing dig methods. [Fix GH-1103] + + * struct.c (rb_struct_dig): [DOC] add rdoc. + Tue Nov 17 11:22:22 2015 Martin Duerst <duerst@it.aoyama.ac.jp> * NEWS: Small grammatical fix [ci skip] @@ -5535,8 +5535,8 @@ rb_ary_any_p(VALUE ary) * call-seq: * ary.dig(idx, ...) -> object * - * Retrieves the value object corresponding to the each <i>idx</i> - * objects repeatedly. + * Extracts the nested array value specified by the sequence of <i>idx</i> + * objects. * * a = [[1, [2, 3]]] * @@ -2695,8 +2695,8 @@ rb_hash_any_p(VALUE hash) * call-seq: * hsh.dig(key, ...) -> object * - * Retrieves the value object corresponding to the each <i>key</i> - * objects repeatedly. + * Extracts the nested hash value specified by the sequence of <i>key</i> + * objects. * * h = { foo: {bar: {baz: 1}}} * @@ -1126,6 +1126,20 @@ rb_struct_size(VALUE s) return LONG2FIX(RSTRUCT_LEN(s)); } +/* + * call-seq: + * struct.dig(key, ...) -> object + * + * Extracts the nested struct value specified by the sequence of <i>key</i> + * objects. + * + * klass = Struct.new(:a) + * o = klass.new(klass.new({b: [1, 2, 3]})) + * + * o.dig(:a, :a, :b, 0) #=> 1 + * o.dig(:b, 0) #=> nil + */ + static VALUE rb_struct_dig(int argc, VALUE *argv, VALUE self) { |