class Concurrent::Map
def [](key)
Experimental RBS support (using type sampling data from the type_fusion project).
type Concurrent__Map_[]_key = String | Symbol | Integer | Thread | Array[] | Array[Symbol] | nil | Hash type Concurrent__Map_[]_return_value = ActiveRecord::ConnectionAdapters::PoolManager | ActiveSupport::Inflector::Inflections | String | Concurrent::Map | ActiveRecord::ConnectionAdapters::PostgreSQLAdapter | nil | ActionView::Template | ActionView::TemplateDetails::Requested | AASM::Base | AASM::StateMachine | AASM::StateMachineStore | ActiveRecord::ConnectionAdapters::SQLite3Adapter | Array[ActiveSupport::Notifications::Fanout::Subscribers::Evented] | Array[] | Array[Symbol] | bool def []: (Concurrent__Map_[]_key key) -> Concurrent__Map_[]_return_value
This signature was generated using 2742 samples from 8 applications.
-
(Object)- the value
Parameters:
-
key(Object) --
def [](key) if value = super # non-falsy value is an existing mapping, return it right away value # re-check is done with get_or_default(key, NULL) instead of a simple !key?(key) in order to avoid a race condition, whereby by the time the current thread gets to the key?(key) call # a key => value mapping might have already been created by a different thread (key?(key) would then return true, this elsif branch wouldn't be taken and an incorrent +nil+ value # would be returned) # note: nil == value check is not technically necessary elsif @default_proc && nil == value && NULL == (value = get_or_default(key, NULL)) @default_proc.call(self, key) else value end end