Method: Immutable::Hash#assoc
- Defined in:
- lib/immutable/hash.rb
#assoc(obj) ⇒ Array
Searches through the Hash, comparing obj with each key (using ‘#==`). When a matching key is found, return the `[key, value]` pair as an array. Return nil if no match is found.
701 702 703 704 |
# File 'lib/immutable/hash.rb', line 701 def assoc(obj) each { |entry| return entry if obj == entry[0] } nil end |