instance method []

Ruby on Rails 5.0.7.2

Since v5.0.7.2 Last seen in v5.0.7.2

Signature

[](key)

Same as Hash#[] where the key passed as argument can be either a string or a symbol:

counters = ActiveSupport::HashWithIndifferentAccess.new
counters[:foo] = 1

counters['foo'] # => 1
counters[:foo]  # => 1
counters[:zoo]  # => nil

Parameters

key req
Source
# File activesupport/lib/active_support/hash_with_indifferent_access.rb, line 180
    def [](key)
      super(convert_key(key))
    end

Defined in activesupport/lib/active_support/hash_with_indifferent_access.rb line 180 · View on GitHub · Improve this page · Find usages on GitHub

Defined in HashWithIndifferentAccess

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close