concept key in category ruby

This is an excerpt from Manning's book The Well-Grounded Rubyist, Third Edition.
RbConfig::CONFIG is a constant referring to the hash (a kind of data structure) where Ruby keeps its configuration knowledge. The string "bindir" is a hash key. Querying the hash with the "bindir" key gives you the corresponding hash value, which is the name of the binary-file installation directory.
Hashes are also ordered collections. Hashes store objects in pairs, each pair consisting of a key and a value. You retrieve a value by means of the key. Hashes remember the order in which their keys were inserted; that’s the order in which the hash replays itself for you if you iterate through the pairs in it or print a string representation of it to the screen.
Any Ruby object can serve as a hash key and/or value, but keys are unique per hash: you can have only one key/value pair for any given key. Hashes (or similar data storage types) are sometimes called dictionaries or associative arrays in other languages. They offer a tremendously—sometimes surprisingly—powerful way of storing and retrieving data.
Arrays and hashes are closely connected. An array is, in a sense, a hash, where the keys happen to be consecutive integers. Hashes are, in a sense, arrays, where the indexes are allowed to be anything, not just integers. Although both arrays and hashes are “keyed,” hash keys are more intentional because they’re determined by the programmer. For this reason, hashes are often thought of in key/value pairs. In this way, hashes exhibit a kind of “meta-index” property. A hash’s key/value pairs can be counted off consecutively. You can see this property in action by stepping through a hash with the with_index method, which yields a counter value to the block along with the key and value:
It’s important to remember that whatever you specify as the default value is what you get when you specify a nonexistent key—and that the key remains nonexistent until you assign a value to it. In other words, saying h["blah"] doesn’t mean that h now has a "blah" key. If you want that key in the hash, you have to put it there. You can verify the fact that the hash h has no keys by examining it after performing the nonexistent-key lookup in the last example:
>> h => {}If you want references to nonexistent keys to cause the keys to come into existence, you can arrange this by supplying a code block to Hash.new. The code block will be executed every time a nonexistent key is referenced. Two objects will be yielded to the block: the hash and the (nonexistent) key.
This technique gives you a foot in the door when it comes to setting keys automatically when they’re first used. It’s not the most elegant or streamlined technique in Ruby, but it does work. You write a block that grabs the hash and the key, and you do a set operation.