summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-struct
diff options
context:
space:
mode:
authorWataru Ashihara <[email protected]>2019-02-24 16:57:22 +0900
committerWataru Ashihara <[email protected]>2019-02-24 16:59:02 +0900
commite91f3ec770e2dd5e2828e510f8566f86136d9f6a (patch)
tree508e2dc4b11ab3550418c010ac9ab5f363e680de /mrbgems/mruby-struct
parentf5cfb77078994dfbe35ef264df7e8f52cffb4a5d (diff)
downloadmruby-e91f3ec770e2dd5e2828e510f8566f86136d9f6a.tar.gz
mruby-e91f3ec770e2dd5e2828e510f8566f86136d9f6a.zip
Move `Object#dig` to `Struct#dig`
This method seems to be mistakenly put into `Object` instead of `Struct` since it's in `struct.rb` and daf83946b says: add #dig to Array,Hash and Struct
Diffstat (limited to 'mrbgems/mruby-struct')
-rw-r--r--mrbgems/mruby-struct/mrblib/struct.rb31
1 files changed, 15 insertions, 16 deletions
diff --git a/mrbgems/mruby-struct/mrblib/struct.rb b/mrbgems/mruby-struct/mrblib/struct.rb
index 7cf3dd3ab..c5b5354be 100644
--- a/mrbgems/mruby-struct/mrblib/struct.rb
+++ b/mrbgems/mruby-struct/mrblib/struct.rb
@@ -81,23 +81,22 @@ if Object.const_defined?(:Struct)
# 15.2.18.4.11(x)
#
alias to_s inspect
- end
- ##
- # call-seq:
- # hsh.dig(key,...) -> object
- #
- # Extracts the nested value specified by the sequence of <i>key</i>
- # objects by calling +dig+ at each step, returning +nil+ if any
- # intermediate step is +nil+.
- #
- def dig(idx,*args)
- n = self[idx]
- if args.size > 0
- n&.dig(*args)
- else
- n
+ ##
+ # call-seq:
+ # hsh.dig(key,...) -> object
+ #
+ # Extracts the nested value specified by the sequence of <i>key</i>
+ # objects by calling +dig+ at each step, returning +nil+ if any
+ # intermediate step is +nil+.
+ #
+ def dig(idx,*args)
+ n = self[idx]
+ if args.size > 0
+ n&.dig(*args)
+ else
+ n
+ end
end
end
end
-