aboutsummaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 05:21:11 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 05:21:11 +0000
commit994de97db4704a7bc50e452b153d743e8c96c57f (patch)
tree0e7faca165921fba08b4e438f23049ef400dff99 /hash.c
parentfc758346e8825efd6652edfc29f89844280482e7 (diff)
downloadruby-994de97db4704a7bc50e452b153d743e8c96c57f.tar.gz
* array.c: Improve and fix documentation for Array#dig
[#11776] * hash.c: ditto * struct.c: ditto * test_hash.rb: Add basic test for user defined `dig`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index b0489502b0..1fd9d12e15 100644
--- a/hash.c
+++ b/hash.c
@@ -2695,13 +2695,17 @@ rb_hash_any_p(VALUE hash)
* call-seq:
* hsh.dig(key, ...) -> object
*
- * Extracts the nested hash value specified by the sequence of <i>key</i>
- * objects.
+ * Extracts the nested value specified by the sequence of <i>idx</i>
+ * objects by calling +dig+ at each step, returning +nil+ if any
+ * intermediate step is +nil+.
*
* h = { foo: {bar: {baz: 1}}}
*
* h.dig(:foo, :bar, :baz) #=> 1
- * h.dig(:foo, :zot) #=> nil
+ * h.dig(:foo, :zot, :xyz) #=> nil
+ *
+ * g = { foo: [10, 11, 12] }
+ * g.dig(:foo, 1) #=> 11
*/
VALUE