diff options
author | Burdette Lamar <BurdetteLamar@Yahoo.com> | 2020-08-13 13:16:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-13 13:16:27 -0500 |
commit | 22fd617aa5a8dd9c8426a546e0cb8a64b45c230b (patch) | |
tree | faed339ece1bb59fb3dc0e67184127bb75e67589 /struct.c | |
parent | cead77d809e2a7610afc68c395f12007472a72a7 (diff) |
Adding doc/dig_methods.rdoc and links to it (#3416)
Adds a full discussion of #dig, along with links from Array, Hash, Struct, and OpenStruct.
CSV::Table and CSV::Row are over in ruby/csv. I'll get to them soon.
The art to the thing is to figure out how much (or how little) to say at each #dig.
Notes
Notes:
Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
Diffstat (limited to 'struct.c')
-rw-r--r-- | struct.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -1328,18 +1328,21 @@ rb_struct_size(VALUE s) /* * call-seq: - * struct.dig(key, ...) -> object + * struct.dig(key, *identifiers) -> object * - * Extracts the nested value specified by the sequence of +key+ - * objects by calling +dig+ at each step, returning +nil+ if any - * intermediate step is +nil+. + * Finds and returns the object in nested objects + * that is specified by +key+ and +identifiers+. + * The nested objects may be instances of various classes. + * See {Dig Methods}[doc/dig_methods_rdoc.html]. * + * Examples: * Foo = Struct.new(:a) * f = Foo.new(Foo.new({b: [1, 2, 3]})) - * - * f.dig(:a, :a, :b, 0) # => 1 - * f.dig(:b, 0) # => nil - * f.dig(:a, :a, :b, :c) # TypeError: no implicit conversion of Symbol into Integer + * f.dig(:a) # => #<struct Foo a={:b=>[1, 2, 3]}> + * f.dig(:a, :a) # => {:b=>[1, 2, 3]} + * f.dig(:a, :a, :b) # => [1, 2, 3] + * f.dig(:a, :a, :b, 0) # => 1 + * f.dig(:b, 0) # => nil */ static VALUE |