summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-17 02:25:28 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-17 02:25:28 +0000
commit0701e5ff4641f364e39b9b6036afeecb3a816a5a (patch)
tree3ac6cf8c124af7479c019b02c92ad8265954316e /struct.c
parent8e465f9c99a8a8db4ab36d21b87d29b9acf99fc0 (diff)
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
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c14
1 files changed, 14 insertions, 0 deletions
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 <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)
{