Class: Hash

Inherits:
Object show all
Includes:
HashBFS, HashSymbolizeKeysRecursive, HashUnion, Tins::Subhash
Defined in:
lib/tins/xt/hash_bfs.rb,
lib/tins/xt/hash_symbolize_keys_recursive.rb,
lib/tins/xt/hash_union.rb,
lib/tins/xt/subhash.rb

Direct Known Subclasses

Tins::Bijection, Tins::DynamicScope::Context

Instance Method Summary collapse

Methods included from Tins::Subhash

#subhash

Instance Method Details

#subhash!(*patterns) ⇒ Hash

The subhash! method creates a filtered subset of this hash based on the given patterns and replaces the current hash with the result.

This method works by first calling subhash with the provided patterns to create a new hash containing only the matching key-value pairs, then replacing the contents of the current hash with those pairs.

keys filtered subset

Parameters:

  • patterns (Array<Object>)

    One or more patterns to match against

Returns:

  • (Hash)

    Returns self after replacing its contents with the



18
19
20
# File 'lib/tins/xt/subhash.rb', line 18

def subhash!(*patterns)
  replace subhash(*patterns)
end