instance method
assoc
Ruby on Rails edge
Since v5.2.8.1Signature
assoc(key)
Same as ‘Hash#assoc` where the key passed as argument can be either a string or a symbol:
“‘ counters = ActiveSupport::HashWithIndifferentAccess.new counters = 1
counters.assoc(‘foo’) # => [“foo”, 1] counters.assoc(:foo) # => [“foo”, 1] counters.assoc(:zoo) # => nil “‘
Parameters
-
keyreq
Source
# File activesupport/lib/active_support/hash_with_indifferent_access.rb, line 225
def assoc(key)
super(convert_key(key))
end
Defined in activesupport/lib/active_support/hash_with_indifferent_access.rb line 225
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::HashWithIndifferentAccess