A hash key identifies the value retrieved from a hash. Hashes store key/value pairs, and both keys and values can be Ruby objects. section 9.3
Looking up a state abbreviation
A state-name string can serve as a key: looking up state_hash[state] retrieves the matching two-letter abbreviation. If the entered state is not defined, the lookup does not produce one of the stored abbreviations. section 9.3
Hash keys support several practical patterns:
- Use strings, symbols, or other Ruby objects as keys. section 9.3 section 8.2.3
- Preserve key insertion order, which becomes visible during iteration. section 9.3
- Use keys for more than direct retrieval, including filtering and selection operations. section 9.3
