instance method
assoc
Ruby on Rails 6.1.7.10
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[:foo] = 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 177
def assoc(key)
super(convert_key(key))
end
Defined in activesupport/lib/active_support/hash_with_indifferent_access.rb line 177
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::HashWithIndifferentAccess