From 0701e5ff4641f364e39b9b6036afeecb3a816a5a Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 17 Nov 2015 02:25:28 +0000 Subject: [PATCH] update rdoc of dig methods [ci skip] * 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ array.c | 4 ++-- hash.c | 4 ++-- struct.c | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78928e8a8e..1d472a4702 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue Nov 17 11:25:05 2015 Eric Turner + + * 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 * NEWS: Small grammatical fix [ci skip] diff --git a/array.c b/array.c index 7469cc2387..8f8eb1e8d9 100644 --- a/array.c +++ b/array.c @@ -5535,8 +5535,8 @@ rb_ary_any_p(VALUE ary) * call-seq: * ary.dig(idx, ...) -> object * - * Retrieves the value object corresponding to the each idx - * objects repeatedly. + * Extracts the nested array value specified by the sequence of idx + * objects. * * a = [[1, [2, 3]]] * diff --git a/hash.c b/hash.c index c724b2e2b5..717a548a31 100644 --- a/hash.c +++ b/hash.c @@ -2695,8 +2695,8 @@ rb_hash_any_p(VALUE hash) * call-seq: * hsh.dig(key, ...) -> object * - * Retrieves the value object corresponding to the each key - * objects repeatedly. + * Extracts the nested hash value specified by the sequence of key + * objects. * * h = { foo: {bar: {baz: 1}}} * diff --git a/struct.c b/struct.c index d8c781efa6..cebc445a43 100644 --- a/struct.c +++ b/struct.c @@ -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 key + * 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) {