instance method
dig
Ruby on Rails 7.0.10
Since v5.2.8.1Signature
dig(*args)
Same as Hash#dig where the key passed as argument can be either a string or a symbol:
counters = ActiveSupport::HashWithIndifferentAccess.new counters[:foo] = { bar: 1 } counters.dig('foo', 'bar') # => 1 counters.dig(:foo, :bar) # => 1 counters.dig(:zoo) # => nil
Parameters
-
argsrest
Source
# File activesupport/lib/active_support/hash_with_indifferent_access.rb, line 206
def dig(*args)
args[0] = convert_key(args[0]) if args.size > 0
super(*args)
end
Defined in activesupport/lib/active_support/hash_with_indifferent_access.rb line 206
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::HashWithIndifferentAccess