summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 05:21:11 (GMT)
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-08 05:21:11 (GMT)
commitcb3b463a50dee9d4e3d174dc9b1d7c8181678cd4 (patch)
tree0e7faca165921fba08b4e438f23049ef400dff99 /array.c
parent1fadd438811426523a79ccea93a45f0a202a50f6 (diff)
* 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 'array.c')
-rw-r--r--array.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/array.c b/array.c
index 159dc8f..dd14837 100644
--- a/array.c
+++ b/array.c
@@ -5535,13 +5535,16 @@ rb_ary_any_p(VALUE ary)
* call-seq:
* ary.dig(idx, ...) -> object
*
- * Extracts the nested array value specified by the sequence of <i>idx</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+.
*
* a = [[1, [2, 3]]]
*
* a.dig(0, 1, 1) #=> 3
- * a.dig(0, 0, 0) #=> nil
+ * a.dig(1, 2, 3) #=> nil
+ * a.dig(0, 0, 0) #=> NoMethodError, undefined method `dig' for 1:Fixnum
+ * [42, {foo: :bar}].dig(1, :foo) #=> :bar
*/
VALUE