Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

PStore#[]

[](key)

Returns the value for the given key if the key exists. nil otherwise; if not nil, the returned value is an object or a hierarchy of objects:

Example
example_store do |store|
  store.transaction do
    store[:foo]  # => 0
    store[:nope] # => nil
  end
end

Returns nil if there is no such key.

See also Hierarchical Values.

Raises an exception if called outside a transaction block.

See also #[]= .new #abort also in 3.4 · 3.3 · 3.1 · 3.0